2010年7月10日土曜日

virtualenv が上手く動作しない場合は -p オプションと --distribute オプションを試す

Python Hackathon  virtualenv  buildout 

virtualenv
pythonsite-package
python virtualenv.py --no-site-package myenv
Mac OS X 10.6Python 2.6.1
New python executable in foo/bin/python
ERROR: The executable foo/bin/python is not functioning
ERROR: It thinks sys.prefix is '/System/Library/Frameworks/Python.framework/Versions/2.6' (should be '/private/tmp/virtualenv-1.4.3/foo')
ERROR: virtualenv is not compatible with this system or executable
 https:/
/bitbucket.org/ianb/virtualenv/issue/17/virtualenv-not-working-with-default-python-on-mac-os 
python virtualenv.py --no-site-package -p /usr/bin/python myenv
-p使
Python


buildout
buildoutbootstrap.pyMac OS X 10.6Python 2.6.1setuptools0.6c9
akisute server$ python bootstrap.py 
The required version of setuptools (>=0.6c11) is not available, and
can't be installed while this script is running. Please install
a more recent version first, using 'easy_install -U setuptools'.

(Currently using setuptools 0.6c9 (/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python))
setuptools--distribute使
python bootstrap.py --distribute
distribute
setuptoolsbuildoutbuildout

2010年7月7日水曜日

Core Graphics (Quartz) のみで日本語文字列を描画するライブラリのヘッダファイルを書いてみた

 UIKit 使 Core Graphics 調




Core Graphics 調
http://iphone-dev.g.hatena.ne.jp/ktakayama/20100129
http://d.hatena.ne.jp/r_kurain/20100316
 CGContextSetTextMatrix 使調

 CGFontGetGlyphsForUnichars 使API使


http://www.mexircus.com/codes/GlyphDrawing.mm
使 CGFontGetGlyphsForUnichars  CMFontGetGlyphsForUnichars 

mm使




 GlyphDrawing.h 
http://gist.github.com/466297

 GlyphDrawing.mm  GlyphDrawing.mm  (http://mexircus.com/blog/) 


使
(一)http://gist.github.com/466297  http://www.mexircus.com/codes/GlyphDrawing.mm 
(二)GlyphDrawing.mm :
//#import <Foundation/Foundation.h>
#import "GlyphDrawing.h"

(三)GlyphDrawing.h  GlyphDrawing.mm 
(四)CGFontGetGlyphsForUnichars  CMFontGetGlyphsForUnichars OK


使
NSString *message = @"本日は快晴なり";

// フォントを設定
// ついでにmessageのサイズも取得
// ただしsizeWithFontは UIGraphics の機能なので、本当に Core Graphics だけで描画したいならここで使ってはいけません
UIFont *font = [UIFont fontWithName:@"HiraKakuProN-W6" size:32.0];
CGRect messageRect = [message sizeWithFont:font];
CGFontRef fontRef = CGFontCreateWithFontName((CFStringRef)font.fontName);
CGContextSetFont(c, fontRef);
CGContextSetFontSize(c, font.pointSize);

// Glyphを作成
size_t length = [message length];
CGGlyph glyphs[length];
UniChar chars[length];
[message getCharacters:chars range:NSMakeRange(0, length)];
CMFontGetGlyphsForUnichars(fontRef, chars, glyphs, length);

// 文字列が上下反対になるのを防止する
CGAffineTransform transform = CGAffineTransformMakeScale(1.0, -1.0);
CGContextSetTextMatrix(c, transform);
CGContextTranslateCTM(c, 0, messageRect.size.height/2);

// 描画
CGFloat x = 100.0f;
CGFloat y = 100.0f;
CGContextShowGlyphsAtPoint(c, x, y, glyphs, length);