Comments (4)
Rendering Chinese characters shouldn't be a problem, what exactly doesn't work?
from freetype-py.
from freetype-py.
Here is example 1 quickly adapted to do Chinese. As I expected, just using a chinese-capable font and a chinese phrase would do, so the change is only two lines:
@@ -45,8 +45,8 @@ def main():
matrix = FT_Matrix()
face = FT_Face()
pen = FT_Vector()
- filename= 'Vera.ttf'
- text = 'Hello World !'
+ filename= 'DroidSansFallbackFull.ttf'
+ text = '你好嗎!'
num_chars = len(text)
OTOH, as I mentioned above, python 2.x does strings and unicodes somewhat differently; so this change for example 1 only works on python 3.x. My fix ( #52 ) only fixes unicode processing for the emoji example. TODO.
from freetype-py.
I tested both of these answers for python2, and both work. You can either put this line near the top:
from __future__ import unicode_literals
which enables python 2.x to process strings python 3.x style, or add a decode('utf8')
manually like this:
@@ -45,8 +46,9 @@ def main():
matrix = FT_Matrix()
face = FT_Face()
pen = FT_Vector()
- filename= 'Vera.ttf'
- text = 'Hello World !'
+ filename= 'DroidSansFallbackFull.ttf'
+ text = '你好嗎!'
+ text = text.decode('utf8')
num_chars = len(text)
Both of these work, you only need one of them. The first one is probably easiest.
from freetype-py.
Related Issues (20)
- [Question] How to decode Face.postscript_name? HOT 26
- About emoji from font file error HOT 9
- libfreetype.so when system == Emscripten HOT 11
- Documentation for get_first_char HOT 3
- FT_Exception: (cannot open resource) HOT 21
- Two-factor identification on PyPi HOT 5
- get_cbox() raise "invalid argument" error HOT 3
- Wrong horizontal character positioning in hello world examples HOT 9
- New release with pyinstaller fix HOT 5
- feature request: expose FreeType's COLRv1 API HOT 6
- Please publish .tar.gz sdist archives
- on exit, freetype/__init__.py", line 1233, in __del__ TypeError: 'NoneType' object is not callable HOT 10
- `segfault` with version `2.4.0` HOT 10
- possible memory leaks and issues during finalizer HOT 1
- `load_char` failed for custom fonts with right input HOT 28
- Pyinstaller cannot import module HOT 5
- AttributeError: module 'freetype' has no attribute 'Face' HOT 2
- Please provide non-bundled wheels HOT 7
- Remove the pyinstaller code if there is any more trouble
- Move freetype-py to Freetype organisation ? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freetype-py.