Comments (4)
If the font contains a GB18030 charmap, You use FT_Set_Charmap
or FT_Set_Charmap
, with argument FT_ENCODING_GB2312
(upstream seems to have changed it to FT_ENCODING_PRC
). However, I have a quick look at simsun.ttc itself, and it does not have a GB18030 charmap. In that case, you transcode your input with input.decode("GB18030")
before you pass to font.get_chars()
. This also works in general for most recent fonts. (To be honest, the former is only recommended for very old fonts from the 90's).
from freetype-py.
If my answer wasn't clear, your question happens to be invalid for that particular font - with some fonts from the 90's which has a GB charmap, you can set the default charmap to that. But with simsun.ttc
(or the few versions of that particular microsoft font I have on my hard disk at the moment), which only have unicode charmaps, you just have to transcode your input via the usual python encoding/decoding routines (outside of freetype-py), before you invoke freetype-py routines.
I have a bunch of such old fonts with Copyright 1994-1997, Arphic Technology Co., Ltd.
from the 90's , but recent fonts simply don't have GB charmaps anymore.
from freetype-py.
如果我的答案不清楚,那么您的问题恰好对于该特定字体无效 - 对于 90 年代的某些具有 GB 字符映射的字体,您可以将默认字符映射设置为该字体。但是对于
simsun.ttc
(或者我目前硬盘上的特定微软字体的几个版本),它只有unicode字符映射,你只需要通过通常的python编码/解码例程(在freetype-py之外)对你的输入进行转码),在调用 freetype-py 例程之前。我有一堆
Copyright 1994-1997, Arphic Technology Co., Ltd.
90 年代的旧字体,但最近的字体根本没有 GB 字符映射。
OK,I get it.Thanks for you reply.
from freetype-py.
In the example directory, there are two code examples, font-info.py
and ftdump.py
, both of which shows info of font file, and both contains the available charmaps.
I just updated them on some cosmetic issues, unrelated to the charmap info. They haven't been used much since python 2 days, so some of print statements needs updating.
from freetype-py.
Related Issues (20)
- 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
- Check upstream and sync FT_ENCODING_* naming and additional aliases.
- Bitmap of numbers or letters is incorrect HOT 12
- Add some support for CMAP format 14 (IVS/SVS characters) HOT 13
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.