mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-19 09:51:48 +02:00
font-patcher: Add mixture of ScaleGlyph and ScaleGroups
[why] ScaleGlyph always did scaling only (no translation) based on one reference glyph. ScaleGroups does scaling and translation but can not work with one reference glyph but constructs always a combined bounding box. Missing is a way to scale AND translate, but with only one reference glyph. [how] Invent GlyphsToScale+ keyword, that supports just that. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
5d0c65006d
commit
cd39545628
1 changed files with 16 additions and 4 deletions
18
font-patcher
18
font-patcher
|
@ -6,7 +6,7 @@
|
|||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Change the script version when you edit this script:
|
||||
script_version = "3.4.1"
|
||||
script_version = "3.4.2"
|
||||
|
||||
version = "2.3.0-RC"
|
||||
projectName = "Nerd Fonts"
|
||||
|
@ -776,6 +776,7 @@ class font_patcher:
|
|||
# Here one specific glyph is used as 'scale blueprint'. Other glyphs are
|
||||
# scaled by the same factor as this glyph. This is useful if you have one
|
||||
# 'biggest' glyph and all others should stay relatively in size.
|
||||
# Shifting in addition to scaling can be selected too (see below).
|
||||
# - ScaleGroups:
|
||||
# Here you specify a group of glyphs that should be handled together
|
||||
# with the same scaling and shifting. The basis for it is a 'combined
|
||||
|
@ -785,12 +786,14 @@ class font_patcher:
|
|||
# The ScaleGlyph method: You set 'ScaleGlyph' to the unicode of the reference glyph.
|
||||
# Note that there can be only one per patch-set.
|
||||
# Additionally you set 'GlyphsToScale' that contains all the glyphs that shall be
|
||||
# handled like the reference glyph.
|
||||
# handled (scaled) like the reference glyph.
|
||||
# It is a List of: ((glyph code) or (tuple of two glyph codes that form a closed range))
|
||||
# 'GlyphsToScale': [
|
||||
# 0x0100, 0x0300, 0x0400, # The single glyphs 0x0100, 0x0300, and 0x0400
|
||||
# (0x0200, 0x0210), # All glyphs 0x0200 to 0x0210 including both 0x0200 and 0x0210
|
||||
# ]}
|
||||
# If you want to not only scale but also shift as the refenerce glyph you give the
|
||||
# data as 'GlyphsToScale+'. Note that only one set is used and the plus version is preferred.
|
||||
#
|
||||
# For the ScaleGroup method you define any number groups of glyphs and each group is
|
||||
# handled separately. The combined bounding box of all glyphs in the group is determined
|
||||
|
@ -1324,7 +1327,13 @@ class font_patcher:
|
|||
if 'ScaleGlyph' in scaleRules:
|
||||
# Rewrite to equivalent ScaleGroup
|
||||
group_list = []
|
||||
for i in scaleRules['GlyphsToScale']:
|
||||
if 'GlyphsToScale+' in scaleRules:
|
||||
key = 'GlyphsToScale+'
|
||||
plus = True
|
||||
else:
|
||||
key = 'GlyphsToScale'
|
||||
plus = False
|
||||
for i in scaleRules[key]:
|
||||
if isinstance(i, tuple):
|
||||
group_list.append(range(i[0], i[1] + 1))
|
||||
else:
|
||||
|
@ -1333,6 +1342,9 @@ class font_patcher:
|
|||
scale = self.get_scale_factors(sym_dim, 'pa')[0]
|
||||
scaleRules['ScaleGroups'].append(group_list)
|
||||
scaleRules['scales'].append(scale)
|
||||
if plus:
|
||||
scaleRules['bbdims'].append(sym_dim)
|
||||
else:
|
||||
scaleRules['bbdims'].append(None) # The 'old' style keeps just the scale, not the positioning
|
||||
|
||||
def get_glyph_scale(self, symbol_unicode, scaleRules, symbolFont, dest_unicode):
|
||||
|
|
Loading…
Reference in a new issue