repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
googlefonts/glyphsLib
Lib/glyphsLib/parser.py
Parser._fail
def _fail(self, message, text, i): """Raise an exception with given message and text at i.""" raise ValueError("{}:\n{}".format(message, text[i : i + 79]))
python
def _fail(self, message, text, i): """Raise an exception with given message and text at i.""" raise ValueError("{}:\n{}".format(message, text[i : i + 79]))
Raise an exception with given message and text at i.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/parser.py#L233-L236
googlefonts/glyphsLib
Lib/glyphsLib/builder/names.py
build_stylemap_names
def build_stylemap_names( family_name, style_name, is_bold=False, is_italic=False, linked_style=None ): """Build UFO `styleMapFamilyName` and `styleMapStyleName` based on the family and style names, and the entries in the "Style Linking" section of the "Instances" tab in the "Font Info". The value ...
python
def build_stylemap_names( family_name, style_name, is_bold=False, is_italic=False, linked_style=None ): """Build UFO `styleMapFamilyName` and `styleMapStyleName` based on the family and style names, and the entries in the "Style Linking" section of the "Instances" tab in the "Font Info". The value ...
Build UFO `styleMapFamilyName` and `styleMapStyleName` based on the family and style names, and the entries in the "Style Linking" section of the "Instances" tab in the "Font Info". The value of `styleMapStyleName` can be either "regular", "bold", "italic" or "bold italic", depending on the values of `...
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/names.py#L55-L85
googlefonts/glyphsLib
Lib/glyphsLib/builder/blue_values.py
to_ufo_blue_values
def to_ufo_blue_values(self, ufo, master): """Set postscript blue values from Glyphs alignment zones.""" alignment_zones = master.alignmentZones blue_values = [] other_blues = [] for zone in sorted(alignment_zones): pos = zone.position size = zone.size val_list = blue_values...
python
def to_ufo_blue_values(self, ufo, master): """Set postscript blue values from Glyphs alignment zones.""" alignment_zones = master.alignmentZones blue_values = [] other_blues = [] for zone in sorted(alignment_zones): pos = zone.position size = zone.size val_list = blue_values...
Set postscript blue values from Glyphs alignment zones.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/blue_values.py#L18-L31
googlefonts/glyphsLib
Lib/glyphsLib/builder/blue_values.py
to_glyphs_blue_values
def to_glyphs_blue_values(self, ufo, master): """Sets the GSFontMaster alignmentZones from the postscript blue values.""" zones = [] blue_values = _pairs(ufo.info.postscriptBlueValues) other_blues = _pairs(ufo.info.postscriptOtherBlues) for y1, y2 in blue_values: size = y2 - y1 if y...
python
def to_glyphs_blue_values(self, ufo, master): """Sets the GSFontMaster alignmentZones from the postscript blue values.""" zones = [] blue_values = _pairs(ufo.info.postscriptBlueValues) other_blues = _pairs(ufo.info.postscriptOtherBlues) for y1, y2 in blue_values: size = y2 - y1 if y...
Sets the GSFontMaster alignmentZones from the postscript blue values.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/blue_values.py#L34-L53
googlefonts/glyphsLib
Lib/glyphsLib/builder/filters.py
parse_glyphs_filter
def parse_glyphs_filter(filter_str, is_pre=False): """Parses glyphs custom filter string into a dict object that ufo2ft can consume. Reference: ufo2ft: https://github.com/googlei18n/ufo2ft Glyphs 2.3 Handbook July 2016, p184 Args: filter_str - a string of...
python
def parse_glyphs_filter(filter_str, is_pre=False): """Parses glyphs custom filter string into a dict object that ufo2ft can consume. Reference: ufo2ft: https://github.com/googlei18n/ufo2ft Glyphs 2.3 Handbook July 2016, p184 Args: filter_str - a string of...
Parses glyphs custom filter string into a dict object that ufo2ft can consume. Reference: ufo2ft: https://github.com/googlei18n/ufo2ft Glyphs 2.3 Handbook July 2016, p184 Args: filter_str - a string of glyphs app filter Return: A dictiona...
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/filters.py#L25-L76
googlefonts/glyphsLib
Lib/glyphsLib/util.py
build_ufo_path
def build_ufo_path(out_dir, family_name, style_name): """Build string to use as a UFO path.""" return os.path.join( out_dir, "%s-%s.ufo" % ((family_name or "").replace(" ", ""), (style_name or "").replace(" ", "")), )
python
def build_ufo_path(out_dir, family_name, style_name): """Build string to use as a UFO path.""" return os.path.join( out_dir, "%s-%s.ufo" % ((family_name or "").replace(" ", ""), (style_name or "").replace(" ", "")), )
Build string to use as a UFO path.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/util.py#L26-L33
googlefonts/glyphsLib
Lib/glyphsLib/util.py
write_ufo
def write_ufo(ufo, out_dir): """Write a UFO.""" out_path = build_ufo_path(out_dir, ufo.info.familyName, ufo.info.styleName) logger.info("Writing %s" % out_path) clean_ufo(out_path) ufo.save(out_path)
python
def write_ufo(ufo, out_dir): """Write a UFO.""" out_path = build_ufo_path(out_dir, ufo.info.familyName, ufo.info.styleName) logger.info("Writing %s" % out_path) clean_ufo(out_path) ufo.save(out_path)
Write a UFO.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/util.py#L36-L43
googlefonts/glyphsLib
Lib/glyphsLib/util.py
clean_ufo
def clean_ufo(path): """Make sure old UFO data is removed, as it may contain deleted glyphs.""" if path.endswith(".ufo") and os.path.exists(path): shutil.rmtree(path)
python
def clean_ufo(path): """Make sure old UFO data is removed, as it may contain deleted glyphs.""" if path.endswith(".ufo") and os.path.exists(path): shutil.rmtree(path)
Make sure old UFO data is removed, as it may contain deleted glyphs.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/util.py#L46-L50
googlefonts/glyphsLib
Lib/glyphsLib/util.py
ufo_create_background_layer_for_all_glyphs
def ufo_create_background_layer_for_all_glyphs(ufo_font): # type: (defcon.Font) -> None """Create a background layer for all glyphs in ufo_font if not present to reduce roundtrip differences.""" if "public.background" in ufo_font.layers: background = ufo_font.layers["public.background"] els...
python
def ufo_create_background_layer_for_all_glyphs(ufo_font): # type: (defcon.Font) -> None """Create a background layer for all glyphs in ufo_font if not present to reduce roundtrip differences.""" if "public.background" in ufo_font.layers: background = ufo_font.layers["public.background"] els...
Create a background layer for all glyphs in ufo_font if not present to reduce roundtrip differences.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/util.py#L53-L65
googlefonts/glyphsLib
Lib/glyphsLib/util.py
cast_to_number_or_bool
def cast_to_number_or_bool(inputstr): """Cast a string to int, float or bool. Return original string if it can't be converted. Scientific expression is converted into float. """ if inputstr.strip().lower() == "true": return True elif inputstr.strip().lower() == "false": return F...
python
def cast_to_number_or_bool(inputstr): """Cast a string to int, float or bool. Return original string if it can't be converted. Scientific expression is converted into float. """ if inputstr.strip().lower() == "true": return True elif inputstr.strip().lower() == "false": return F...
Cast a string to int, float or bool. Return original string if it can't be converted. Scientific expression is converted into float.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/util.py#L68-L84
googlefonts/glyphsLib
Lib/glyphsLib/builder/background_image.py
to_ufo_background_image
def to_ufo_background_image(self, ufo_glyph, layer): """Copy the backgound image from the GSLayer to the UFO Glyph.""" image = layer.backgroundImage if image is None: return ufo_image = ufo_glyph.image ufo_image.fileName = image.path ufo_image.transformation = image.transform ufo_gly...
python
def to_ufo_background_image(self, ufo_glyph, layer): """Copy the backgound image from the GSLayer to the UFO Glyph.""" image = layer.backgroundImage if image is None: return ufo_image = ufo_glyph.image ufo_image.fileName = image.path ufo_image.transformation = image.transform ufo_gly...
Copy the backgound image from the GSLayer to the UFO Glyph.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/background_image.py#L26-L36
googlefonts/glyphsLib
Lib/glyphsLib/builder/background_image.py
to_glyphs_background_image
def to_glyphs_background_image(self, ufo_glyph, layer): """Copy the background image from the UFO Glyph to the GSLayer.""" ufo_image = ufo_glyph.image if ufo_image.fileName is None: return image = self.glyphs_module.GSBackgroundImage() image.path = ufo_image.fileName image.transform = Tr...
python
def to_glyphs_background_image(self, ufo_glyph, layer): """Copy the background image from the UFO Glyph to the GSLayer.""" ufo_image = ufo_glyph.image if ufo_image.fileName is None: return image = self.glyphs_module.GSBackgroundImage() image.path = ufo_image.fileName image.transform = Tr...
Copy the background image from the UFO Glyph to the GSLayer.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/background_image.py#L39-L54
googlefonts/glyphsLib
Lib/glyphsLib/builder/guidelines.py
to_ufo_guidelines
def to_ufo_guidelines(self, ufo_obj, glyphs_obj): """Set guidelines.""" guidelines = glyphs_obj.guides if not guidelines: return new_guidelines = [] for guideline in guidelines: new_guideline = {} x, y = guideline.position angle = guideline.angle % 360 if _is_...
python
def to_ufo_guidelines(self, ufo_obj, glyphs_obj): """Set guidelines.""" guidelines = glyphs_obj.guides if not guidelines: return new_guidelines = [] for guideline in guidelines: new_guideline = {} x, y = guideline.position angle = guideline.angle % 360 if _is_...
Set guidelines.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/guidelines.py#L28-L63
googlefonts/glyphsLib
Lib/glyphsLib/builder/guidelines.py
to_glyphs_guidelines
def to_glyphs_guidelines(self, ufo_obj, glyphs_obj): """Set guidelines.""" if not ufo_obj.guidelines: return for guideline in ufo_obj.guidelines: new_guideline = self.glyphs_module.GSGuideLine() name = guideline.name # Locked if name is not None and name.endswith(LOCK...
python
def to_glyphs_guidelines(self, ufo_obj, glyphs_obj): """Set guidelines.""" if not ufo_obj.guidelines: return for guideline in ufo_obj.guidelines: new_guideline = self.glyphs_module.GSGuideLine() name = guideline.name # Locked if name is not None and name.endswith(LOCK...
Set guidelines.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/guidelines.py#L66-L87
4Catalyzer/flask-resty
flask_resty/api.py
Api.add_resource
def add_resource( self, base_rule, base_view, alternate_view=None, alternate_rule=None, id_rule=None, app=None, ): """Add route or routes for a resource. :param str base_rule: The URL rule for the resource. This will be prefixed by...
python
def add_resource( self, base_rule, base_view, alternate_view=None, alternate_rule=None, id_rule=None, app=None, ): """Add route or routes for a resource. :param str base_rule: The URL rule for the resource. This will be prefixed by...
Add route or routes for a resource. :param str base_rule: The URL rule for the resource. This will be prefixed by the API prefix. :param base_view: Class-based view for the resource. :param alternate_view: If specified, an alternate class-based view for the resource. Usu...
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/api.py#L61-L137
4Catalyzer/flask-resty
flask_resty/api.py
Api.add_ping
def add_ping(self, rule, status_code=200, app=None): """Add a ping route. :param str rule: The URL rule. This will not use the API prefix, as the ping endpoint is not really part of the API. :param int status_code: The ping response status code. The default is 200 rather...
python
def add_ping(self, rule, status_code=200, app=None): """Add a ping route. :param str rule: The URL rule. This will not use the API prefix, as the ping endpoint is not really part of the API. :param int status_code: The ping response status code. The default is 200 rather...
Add a ping route. :param str rule: The URL rule. This will not use the API prefix, as the ping endpoint is not really part of the API. :param int status_code: The ping response status code. The default is 200 rather than the more correct 204 because many health checks ...
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/api.py#L150-L165
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
UFOBuilder.masters
def masters(self): """Get an iterator over master UFOs that match the given family_name. """ if self._sources: for source in self._sources.values(): yield source.font return # Store set of actually existing master (layer) ids. This helps with ...
python
def masters(self): """Get an iterator over master UFOs that match the given family_name. """ if self._sources: for source in self._sources.values(): yield source.font return # Store set of actually existing master (layer) ids. This helps with ...
Get an iterator over master UFOs that match the given family_name.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L128-L227
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
UFOBuilder.designspace
def designspace(self): """Get a designspace Document instance that links the masters together and holds instance data. """ if self._designspace_is_complete: return self._designspace self._designspace_is_complete = True list(self.masters) # Make sure that the...
python
def designspace(self): """Get a designspace Document instance that links the masters together and holds instance data. """ if self._designspace_is_complete: return self._designspace self._designspace_is_complete = True list(self.masters) # Make sure that the...
Get a designspace Document instance that links the masters together and holds instance data.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L230-L255
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
UFOBuilder._apply_bracket_layers
def _apply_bracket_layers(self): """Extract bracket layers in a GSGlyph into free-standing UFO glyphs with Designspace substitution rules. As of Glyphs.app 2.6, only single axis bracket layers are supported, we assume the axis to be the first axis in the Designspace. Bracket layer ...
python
def _apply_bracket_layers(self): """Extract bracket layers in a GSGlyph into free-standing UFO glyphs with Designspace substitution rules. As of Glyphs.app 2.6, only single axis bracket layers are supported, we assume the axis to be the first axis in the Designspace. Bracket layer ...
Extract bracket layers in a GSGlyph into free-standing UFO glyphs with Designspace substitution rules. As of Glyphs.app 2.6, only single axis bracket layers are supported, we assume the axis to be the first axis in the Designspace. Bracket layer backgrounds are not round-tripped. ...
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L277-L419
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
GlyphsBuilder.font
def font(self): """Get the GSFont built from the UFOs + designspace.""" if self._font is not None: return self._font # Sort UFOS in the original order from the Glyphs file sorted_sources = self.to_glyphs_ordered_masters() # Convert all full source UFOs to Glyphs mas...
python
def font(self): """Get the GSFont built from the UFOs + designspace.""" if self._font is not None: return self._font # Sort UFOS in the original order from the Glyphs file sorted_sources = self.to_glyphs_ordered_masters() # Convert all full source UFOs to Glyphs mas...
Get the GSFont built from the UFOs + designspace.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L512-L597
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
GlyphsBuilder._valid_designspace
def _valid_designspace(self, designspace): """Make sure that the user-provided designspace has loaded fonts and that names are the same as those from the UFOs. """ # TODO: (jany) really make a copy to avoid modifying the original object copy = designspace # Load only full...
python
def _valid_designspace(self, designspace): """Make sure that the user-provided designspace has loaded fonts and that names are the same as those from the UFOs. """ # TODO: (jany) really make a copy to avoid modifying the original object copy = designspace # Load only full...
Make sure that the user-provided designspace has loaded fonts and that names are the same as those from the UFOs.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L599-L638
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
GlyphsBuilder._fake_designspace
def _fake_designspace(self, ufos): """Build a fake designspace with the given UFOs as sources, so that all builder functions can rely on the presence of a designspace. """ designspace = designspaceLib.DesignSpaceDocument() ufo_to_location = defaultdict(dict) # Make weig...
python
def _fake_designspace(self, ufos): """Build a fake designspace with the given UFOs as sources, so that all builder functions can rely on the presence of a designspace. """ designspace = designspaceLib.DesignSpaceDocument() ufo_to_location = defaultdict(dict) # Make weig...
Build a fake designspace with the given UFOs as sources, so that all builder functions can rely on the presence of a designspace.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L640-L702
googlefonts/glyphsLib
Lib/glyphsLib/builder/kerning.py
_to_ufo_kerning
def _to_ufo_kerning(self, ufo, kerning_data): """Add .glyphs kerning to an UFO.""" warning_msg = "Non-existent glyph class %s found in kerning rules." for left, pairs in kerning_data.items(): match = re.match(r"@MMK_L_(.+)", left) left_is_class = bool(match) if left_is_class: ...
python
def _to_ufo_kerning(self, ufo, kerning_data): """Add .glyphs kerning to an UFO.""" warning_msg = "Non-existent glyph class %s found in kerning rules." for left, pairs in kerning_data.items(): match = re.match(r"@MMK_L_(.+)", left) left_is_class = bool(match) if left_is_class: ...
Add .glyphs kerning to an UFO.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/kerning.py#L27-L46
googlefonts/glyphsLib
Lib/glyphsLib/builder/kerning.py
to_glyphs_kerning
def to_glyphs_kerning(self): """Add UFO kerning to GSFont.""" for master_id, source in self._sources.items(): for (left, right), value in source.font.kerning.items(): left_match = UFO_KERN_GROUP_PATTERN.match(left) right_match = UFO_KERN_GROUP_PATTERN.match(right) if ...
python
def to_glyphs_kerning(self): """Add UFO kerning to GSFont.""" for master_id, source in self._sources.items(): for (left, right), value in source.font.kerning.items(): left_match = UFO_KERN_GROUP_PATTERN.match(left) right_match = UFO_KERN_GROUP_PATTERN.match(right) if ...
Add UFO kerning to GSFont.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/kerning.py#L49-L59
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
_normalize_custom_param_name
def _normalize_custom_param_name(name): """Replace curved quotes with straight quotes in a custom parameter name. These should be the only keys with problematic (non-ascii) characters, since they can be user-generated. """ replacements = (("\u2018", "'"), ("\u2019", "'"), ("\u201C", '"'), ("\u201D"...
python
def _normalize_custom_param_name(name): """Replace curved quotes with straight quotes in a custom parameter name. These should be the only keys with problematic (non-ascii) characters, since they can be user-generated. """ replacements = (("\u2018", "'"), ("\u2019", "'"), ("\u201C", '"'), ("\u201D"...
Replace curved quotes with straight quotes in a custom parameter name. These should be the only keys with problematic (non-ascii) characters, since they can be user-generated.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L757-L766
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
_set_default_params
def _set_default_params(ufo): """ Set Glyphs.app's default parameters when different from ufo2ft ones. """ for _, ufo_name, default_value in DEFAULT_PARAMETERS: if getattr(ufo.info, ufo_name) is None: if isinstance(default_value, list): # Prevent problem if the same defau...
python
def _set_default_params(ufo): """ Set Glyphs.app's default parameters when different from ufo2ft ones. """ for _, ufo_name, default_value in DEFAULT_PARAMETERS: if getattr(ufo.info, ufo_name) is None: if isinstance(default_value, list): # Prevent problem if the same defau...
Set Glyphs.app's default parameters when different from ufo2ft ones.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L781-L790
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
_unset_default_params
def _unset_default_params(glyphs): """ Unset Glyphs.app's parameters that have default values. FIXME: (jany) maybe this should be taken care of in the writer? and/or classes should have better default values? """ for glyphs_name, _, default_value in DEFAULT_PARAMETERS: if ( g...
python
def _unset_default_params(glyphs): """ Unset Glyphs.app's parameters that have default values. FIXME: (jany) maybe this should be taken care of in the writer? and/or classes should have better default values? """ for glyphs_name, _, default_value in DEFAULT_PARAMETERS: if ( g...
Unset Glyphs.app's parameters that have default values. FIXME: (jany) maybe this should be taken care of in the writer? and/or classes should have better default values?
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L793-L809
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
GlyphsObjectProxy.get_custom_value
def get_custom_value(self, key): """Return the first and only custom parameter matching the given name.""" self._handled.add(key) values = self._lookup[key] if len(values) > 1: raise RuntimeError( "More than one value for this customParameter: {}".format(key) ...
python
def get_custom_value(self, key): """Return the first and only custom parameter matching the given name.""" self._handled.add(key) values = self._lookup[key] if len(values) > 1: raise RuntimeError( "More than one value for this customParameter: {}".format(key) ...
Return the first and only custom parameter matching the given name.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L101-L111
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
GlyphsObjectProxy.get_custom_values
def get_custom_values(self, key): """Return a set of values for the given customParameter name.""" self._handled.add(key) return self._lookup[key]
python
def get_custom_values(self, key): """Return a set of values for the given customParameter name.""" self._handled.add(key) return self._lookup[key]
Return a set of values for the given customParameter name.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L113-L116
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
GlyphsObjectProxy.set_custom_value
def set_custom_value(self, key, value): """Set one custom parameter with the given value. We assume that the list of custom parameters does not already contain the given parameter so we only append. """ self._owner.customParameters.append( self._glyphs_module.GSCustom...
python
def set_custom_value(self, key, value): """Set one custom parameter with the given value. We assume that the list of custom parameters does not already contain the given parameter so we only append. """ self._owner.customParameters.append( self._glyphs_module.GSCustom...
Set one custom parameter with the given value. We assume that the list of custom parameters does not already contain the given parameter so we only append.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L118-L125
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
GlyphsObjectProxy.set_custom_values
def set_custom_values(self, key, values): """Set several values for the customParameter with the given key. We append one GSCustomParameter per value. """ for value in values: self.set_custom_value(key, value)
python
def set_custom_values(self, key, values): """Set several values for the customParameter with the given key. We append one GSCustomParameter per value. """ for value in values: self.set_custom_value(key, value)
Set several values for the customParameter with the given key. We append one GSCustomParameter per value.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L127-L132
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSCustomParameter.setValue
def setValue(self, value): """Cast some known data in custom parameters.""" if self.name in self._CUSTOM_INT_PARAMS: value = int(value) elif self.name in self._CUSTOM_FLOAT_PARAMS: value = float(value) elif self.name in self._CUSTOM_BOOL_PARAMS: value ...
python
def setValue(self, value): """Cast some known data in custom parameters.""" if self.name in self._CUSTOM_INT_PARAMS: value = int(value) elif self.name in self._CUSTOM_FLOAT_PARAMS: value = float(value) elif self.name in self._CUSTOM_BOOL_PARAMS: value ...
Cast some known data in custom parameters.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L1254-L1269
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSFontMaster.name
def name(self, name): """This function will take the given name and split it into components weight, width, customName, and possibly the full name. This is what Glyphs 1113 seems to be doing, approximately. """ weight, width, custom_name = self._splitName(name) self.set_a...
python
def name(self, name): """This function will take the given name and split it into components weight, width, customName, and possibly the full name. This is what Glyphs 1113 seems to be doing, approximately. """ weight, width, custom_name = self._splitName(name) self.set_a...
This function will take the given name and split it into components weight, width, customName, and possibly the full name. This is what Glyphs 1113 seems to be doing, approximately.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L1446-L1452
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSFontMaster.set_all_name_components
def set_all_name_components(self, name, weight, width, custom_name): """This function ensures that after being called, the master.name, master.weight, master.width, and master.customName match the given values. """ self.weight = weight or "Regular" self.width = width or "...
python
def set_all_name_components(self, name, weight, width, custom_name): """This function ensures that after being called, the master.name, master.weight, master.width, and master.customName match the given values. """ self.weight = weight or "Regular" self.width = width or "...
This function ensures that after being called, the master.name, master.weight, master.width, and master.customName match the given values.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L1454-L1468
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSNode._encode_dict_as_string
def _encode_dict_as_string(value): """Takes the PLIST string of a dict, and returns the same string encoded such that it can be included in the string representation of a GSNode.""" # Strip the first and last newlines if value.startswith("{\n"): value = "{" + value[2:...
python
def _encode_dict_as_string(value): """Takes the PLIST string of a dict, and returns the same string encoded such that it can be included in the string representation of a GSNode.""" # Strip the first and last newlines if value.startswith("{\n"): value = "{" + value[2:...
Takes the PLIST string of a dict, and returns the same string encoded such that it can be included in the string representation of a GSNode.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L1649-L1659
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSNode._indices
def _indices(self): """Find the path_index and node_index that identify the given node.""" path = self.parent layer = path.parent for path_index in range(len(layer.paths)): if path == layer.paths[path_index]: for node_index in range(len(path.nodes)): ...
python
def _indices(self): """Find the path_index and node_index that identify the given node.""" path = self.parent layer = path.parent for path_index in range(len(layer.paths)): if path == layer.paths[path_index]: for node_index in range(len(path.nodes)): ...
Find the path_index and node_index that identify the given node.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L1677-L1686
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSLayer._find_node_by_indices
def _find_node_by_indices(self, point): """"Find the GSNode that is refered to by the given indices. See GSNode::_indices() """ path_index, node_index = point path = self.paths[int(path_index)] node = path.nodes[int(node_index)] return node
python
def _find_node_by_indices(self, point): """"Find the GSNode that is refered to by the given indices. See GSNode::_indices() """ path_index, node_index = point path = self.paths[int(path_index)] node = path.nodes[int(node_index)] return node
Find the GSNode that is refered to by the given indices. See GSNode::_indices()
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L2909-L2917
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSLayer.background
def background(self): """Only a getter on purpose. See the tests.""" if self._background is None: self._background = GSBackgroundLayer() self._background._foreground = self return self._background
python
def background(self): """Only a getter on purpose. See the tests.""" if self._background is None: self._background = GSBackgroundLayer() self._background._foreground = self return self._background
Only a getter on purpose. See the tests.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L2920-L2925
googlefonts/glyphsLib
Lib/glyphsLib/builder/anchors.py
to_ufo_propagate_font_anchors
def to_ufo_propagate_font_anchors(self, ufo): """Copy anchors from parent glyphs' components to the parent.""" processed = set() for glyph in ufo: _propagate_glyph_anchors(self, ufo, glyph, processed)
python
def to_ufo_propagate_font_anchors(self, ufo): """Copy anchors from parent glyphs' components to the parent.""" processed = set() for glyph in ufo: _propagate_glyph_anchors(self, ufo, glyph, processed)
Copy anchors from parent glyphs' components to the parent.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/anchors.py#L29-L34
googlefonts/glyphsLib
Lib/glyphsLib/builder/anchors.py
_propagate_glyph_anchors
def _propagate_glyph_anchors(self, ufo, parent, processed): """Propagate anchors for a single parent glyph.""" if parent.name in processed: return processed.add(parent.name) base_components = [] mark_components = [] anchor_names = set() to_add = {} for component in parent.compo...
python
def _propagate_glyph_anchors(self, ufo, parent, processed): """Propagate anchors for a single parent glyph.""" if parent.name in processed: return processed.add(parent.name) base_components = [] mark_components = [] anchor_names = set() to_add = {} for component in parent.compo...
Propagate anchors for a single parent glyph.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/anchors.py#L37-L77
googlefonts/glyphsLib
Lib/glyphsLib/builder/anchors.py
_adjust_anchors
def _adjust_anchors(anchor_data, ufo, component): """Adjust anchors to which a mark component may have been attached.""" glyph = ufo[component.baseGlyph] t = Transform(*component.transformation) for anchor in glyph.anchors: # only adjust if this anchor has data and the component also contains ...
python
def _adjust_anchors(anchor_data, ufo, component): """Adjust anchors to which a mark component may have been attached.""" glyph = ufo[component.baseGlyph] t = Transform(*component.transformation) for anchor in glyph.anchors: # only adjust if this anchor has data and the component also contains ...
Adjust anchors to which a mark component may have been attached.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/anchors.py#L100-L111
googlefonts/glyphsLib
Lib/glyphsLib/builder/anchors.py
to_ufo_glyph_anchors
def to_ufo_glyph_anchors(self, glyph, anchors): """Add .glyphs anchors to a glyph.""" for anchor in anchors: x, y = anchor.position anchor_dict = {"name": anchor.name, "x": x, "y": y} glyph.appendAnchor(anchor_dict)
python
def to_ufo_glyph_anchors(self, glyph, anchors): """Add .glyphs anchors to a glyph.""" for anchor in anchors: x, y = anchor.position anchor_dict = {"name": anchor.name, "x": x, "y": y} glyph.appendAnchor(anchor_dict)
Add .glyphs anchors to a glyph.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/anchors.py#L114-L120
googlefonts/glyphsLib
Lib/glyphsLib/builder/anchors.py
to_glyphs_glyph_anchors
def to_glyphs_glyph_anchors(self, ufo_glyph, layer): """Add UFO glif anchors to a GSLayer.""" for ufo_anchor in ufo_glyph.anchors: anchor = self.glyphs_module.GSAnchor() anchor.name = ufo_anchor.name anchor.position = Point(ufo_anchor.x, ufo_anchor.y) layer.anchors.append(anchor)
python
def to_glyphs_glyph_anchors(self, ufo_glyph, layer): """Add UFO glif anchors to a GSLayer.""" for ufo_anchor in ufo_glyph.anchors: anchor = self.glyphs_module.GSAnchor() anchor.name = ufo_anchor.name anchor.position = Point(ufo_anchor.x, ufo_anchor.y) layer.anchors.append(anchor)
Add UFO glif anchors to a GSLayer.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/anchors.py#L123-L129
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
cached_property
def cached_property(func): """Special property decorator that caches the computed property value in the object's instance dict the first time it is accessed. """ name = func.__name__ doc = func.__doc__ def getter(self, name=name): try: return self.__dict__[name] ...
python
def cached_property(func): """Special property decorator that caches the computed property value in the object's instance dict the first time it is accessed. """ name = func.__name__ doc = func.__doc__ def getter(self, name=name): try: return self.__dict__[name] ...
Special property decorator that caches the computed property value in the object's instance dict the first time it is accessed.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L99-L115
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
cos_sin_deg
def cos_sin_deg(deg): """Return the cosine and sin for the given angle in degrees, with special-case handling of multiples of 90 for perfect right angles """ deg = deg % 360.0 if deg == 90.0: return 0.0, 1.0 elif deg == 180.0: return -1.0, 0 elif deg == 270.0: ret...
python
def cos_sin_deg(deg): """Return the cosine and sin for the given angle in degrees, with special-case handling of multiples of 90 for perfect right angles """ deg = deg % 360.0 if deg == 90.0: return 0.0, 1.0 elif deg == 180.0: return -1.0, 0 elif deg == 270.0: ret...
Return the cosine and sin for the given angle in degrees, with special-case handling of multiples of 90 for perfect right angles
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L118-L131
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.scale
def scale(cls, *scaling): """Create a scaling transform from a scalar or vector. :param scaling: The scaling factor. A scalar value will scale in both dimensions equally. A vector scaling value scales the dimensions independently. :type scaling: float or sequence ...
python
def scale(cls, *scaling): """Create a scaling transform from a scalar or vector. :param scaling: The scaling factor. A scalar value will scale in both dimensions equally. A vector scaling value scales the dimensions independently. :type scaling: float or sequence ...
Create a scaling transform from a scalar or vector. :param scaling: The scaling factor. A scalar value will scale in both dimensions equally. A vector scaling value scales the dimensions independently. :type scaling: float or sequence :rtype: Affine
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L184-L197
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.shear
def shear(cls, x_angle=0, y_angle=0): """Create a shear transform along one or both axes. :param x_angle: Angle in degrees to shear along the x-axis. :type x_angle: float :param y_angle: Angle in degrees to shear along the y-axis. :type y_angle: float :rtype: Affine ...
python
def shear(cls, x_angle=0, y_angle=0): """Create a shear transform along one or both axes. :param x_angle: Angle in degrees to shear along the x-axis. :type x_angle: float :param y_angle: Angle in degrees to shear along the y-axis. :type y_angle: float :rtype: Affine ...
Create a shear transform along one or both axes. :param x_angle: Angle in degrees to shear along the x-axis. :type x_angle: float :param y_angle: Angle in degrees to shear along the y-axis. :type y_angle: float :rtype: Affine
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L200-L211
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.rotation
def rotation(cls, angle, pivot=None): """Create a rotation transform at the specified angle, optionally about the specified pivot point. :param angle: Rotation angle in degrees :type angle: float :param pivot: Point to rotate about, if omitted the rotation is about t...
python
def rotation(cls, angle, pivot=None): """Create a rotation transform at the specified angle, optionally about the specified pivot point. :param angle: Rotation angle in degrees :type angle: float :param pivot: Point to rotate about, if omitted the rotation is about t...
Create a rotation transform at the specified angle, optionally about the specified pivot point. :param angle: Rotation angle in degrees :type angle: float :param pivot: Point to rotate about, if omitted the rotation is about the origin. :type pivot: sequence ...
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L214-L243
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.determinant
def determinant(self): """The determinant of the transform matrix. This value is equal to the area scaling factor when the transform is applied to a shape. """ a, b, c, d, e, f, g, h, i = self return a * e - b * d
python
def determinant(self): """The determinant of the transform matrix. This value is equal to the area scaling factor when the transform is applied to a shape. """ a, b, c, d, e, f, g, h, i = self return a * e - b * d
The determinant of the transform matrix. This value is equal to the area scaling factor when the transform is applied to a shape.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L267-L273
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.is_rectilinear
def is_rectilinear(self): """True if the transform is rectilinear, i.e., whether a shape would remain axis-aligned, within rounding limits, after applying the transform. """ a, b, c, d, e, f, g, h, i = self return (abs(a) < EPSILON and abs(e) < EPSILON) or ( a...
python
def is_rectilinear(self): """True if the transform is rectilinear, i.e., whether a shape would remain axis-aligned, within rounding limits, after applying the transform. """ a, b, c, d, e, f, g, h, i = self return (abs(a) < EPSILON and abs(e) < EPSILON) or ( a...
True if the transform is rectilinear, i.e., whether a shape would remain axis-aligned, within rounding limits, after applying the transform.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L283-L291
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.is_conformal
def is_conformal(self): """True if the transform is conformal, i.e., if angles between points are preserved after applying the transform, within rounding limits. This implies that the transform has no effective shear. """ a, b, c, d, e, f, g, h, i = self return abs(a * b ...
python
def is_conformal(self): """True if the transform is conformal, i.e., if angles between points are preserved after applying the transform, within rounding limits. This implies that the transform has no effective shear. """ a, b, c, d, e, f, g, h, i = self return abs(a * b ...
True if the transform is conformal, i.e., if angles between points are preserved after applying the transform, within rounding limits. This implies that the transform has no effective shear.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L294-L300
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.is_orthonormal
def is_orthonormal(self): """True if the transform is orthonormal, which means that the transform represents a rigid motion, which has no effective scaling or shear. Mathematically, this means that the axis vectors of the transform matrix are perpendicular and unit-length. Applying an ...
python
def is_orthonormal(self): """True if the transform is orthonormal, which means that the transform represents a rigid motion, which has no effective scaling or shear. Mathematically, this means that the axis vectors of the transform matrix are perpendicular and unit-length. Applying an ...
True if the transform is orthonormal, which means that the transform represents a rigid motion, which has no effective scaling or shear. Mathematically, this means that the axis vectors of the transform matrix are perpendicular and unit-length. Applying an orthonormal transform to a sha...
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L303-L315
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.column_vectors
def column_vectors(self): """The values of the transform as three 2D column vectors""" a, b, c, d, e, f, _, _, _ = self return (a, d), (b, e), (c, f)
python
def column_vectors(self): """The values of the transform as three 2D column vectors""" a, b, c, d, e, f, _, _, _ = self return (a, d), (b, e), (c, f)
The values of the transform as three 2D column vectors
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L326-L329
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.almost_equals
def almost_equals(self, other): """Compare transforms for approximate equality. :param other: Transform being compared. :type other: Affine :return: True if absolute difference between each element of each respective tranform matrix < ``EPSILON``. """ for i i...
python
def almost_equals(self, other): """Compare transforms for approximate equality. :param other: Transform being compared. :type other: Affine :return: True if absolute difference between each element of each respective tranform matrix < ``EPSILON``. """ for i i...
Compare transforms for approximate equality. :param other: Transform being compared. :type other: Affine :return: True if absolute difference between each element of each respective tranform matrix < ``EPSILON``.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L331-L342
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.itransform
def itransform(self, seq): """Transform a sequence of points or vectors in place. :param seq: Mutable sequence of :class:`~planar.Vec2` to be transformed. :returns: None, the input sequence is mutated in place. """ if self is not identity and self != identity: ...
python
def itransform(self, seq): """Transform a sequence of points or vectors in place. :param seq: Mutable sequence of :class:`~planar.Vec2` to be transformed. :returns: None, the input sequence is mutated in place. """ if self is not identity and self != identity: ...
Transform a sequence of points or vectors in place. :param seq: Mutable sequence of :class:`~planar.Vec2` to be transformed. :returns: None, the input sequence is mutated in place.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L405-L415
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
get_glyph
def get_glyph(glyph_name, data=None): """Return a named tuple (Glyph) containing information derived from a glyph name akin to GSGlyphInfo. The information is derived from an included copy of GlyphData.xml and GlyphData_Ideographs.xml, going purely by the glyph name. """ # Read data on first u...
python
def get_glyph(glyph_name, data=None): """Return a named tuple (Glyph) containing information derived from a glyph name akin to GSGlyphInfo. The information is derived from an included copy of GlyphData.xml and GlyphData_Ideographs.xml, going purely by the glyph name. """ # Read data on first u...
Return a named tuple (Glyph) containing information derived from a glyph name akin to GSGlyphInfo. The information is derived from an included copy of GlyphData.xml and GlyphData_Ideographs.xml, going purely by the glyph name.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L89-L139
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
_lookup_attributes
def _lookup_attributes(glyph_name, data): """Look up glyph attributes in data by glyph name, alternative name or production name in order or return empty dictionary. Look up by alternative and production names for legacy projects and because of issue #232. """ attributes = ( data.names....
python
def _lookup_attributes(glyph_name, data): """Look up glyph attributes in data by glyph name, alternative name or production name in order or return empty dictionary. Look up by alternative and production names for legacy projects and because of issue #232. """ attributes = ( data.names....
Look up glyph attributes in data by glyph name, alternative name or production name in order or return empty dictionary. Look up by alternative and production names for legacy projects and because of issue #232.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L142-L155
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
_agl_compliant_name
def _agl_compliant_name(glyph_name): """Return an AGL-compliant name string or None if we can't make one.""" MAX_GLYPH_NAME_LENGTH = 63 clean_name = re.sub("[^0-9a-zA-Z_.]", "", glyph_name) if len(clean_name) > MAX_GLYPH_NAME_LENGTH: return None return clean_name
python
def _agl_compliant_name(glyph_name): """Return an AGL-compliant name string or None if we can't make one.""" MAX_GLYPH_NAME_LENGTH = 63 clean_name = re.sub("[^0-9a-zA-Z_.]", "", glyph_name) if len(clean_name) > MAX_GLYPH_NAME_LENGTH: return None return clean_name
Return an AGL-compliant name string or None if we can't make one.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L158-L164
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
_construct_category
def _construct_category(glyph_name, data): """Derive (sub)category of a glyph name.""" # Glyphs creates glyphs that start with an underscore as "non-exportable" glyphs or # construction helpers without a category. if glyph_name.startswith("_"): return None, None # Glyph variants (e.g. "fi.a...
python
def _construct_category(glyph_name, data): """Derive (sub)category of a glyph name.""" # Glyphs creates glyphs that start with an underscore as "non-exportable" glyphs or # construction helpers without a category. if glyph_name.startswith("_"): return None, None # Glyph variants (e.g. "fi.a...
Derive (sub)category of a glyph name.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L174-L233
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
_translate_category
def _translate_category(glyph_name, unicode_category): """Return a translation from Unicode category letters to Glyphs categories.""" DEFAULT_CATEGORIES = { None: ("Letter", None), "Cc": ("Separator", None), "Cf": ("Separator", "Format"), "Cn": ("Symbol", None), "Co":...
python
def _translate_category(glyph_name, unicode_category): """Return a translation from Unicode category letters to Glyphs categories.""" DEFAULT_CATEGORIES = { None: ("Letter", None), "Cc": ("Separator", None), "Cf": ("Separator", "Format"), "Cn": ("Symbol", None), "Co":...
Return a translation from Unicode category letters to Glyphs categories.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L236-L279
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
_construct_production_name
def _construct_production_name(glyph_name, data=None): """Return the production name for a glyph name from the GlyphData.xml database according to the AGL specification. This should be run only if there is no official entry with a production name in it. Handles single glyphs (e.g. "brevecomb") and...
python
def _construct_production_name(glyph_name, data=None): """Return the production name for a glyph name from the GlyphData.xml database according to the AGL specification. This should be run only if there is no official entry with a production name in it. Handles single glyphs (e.g. "brevecomb") and...
Return the production name for a glyph name from the GlyphData.xml database according to the AGL specification. This should be run only if there is no official entry with a production name in it. Handles single glyphs (e.g. "brevecomb") and ligatures (e.g. "brevecomb_acutecomb"). Returns None when...
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L282-L384
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
GlyphData.from_files
def from_files(cls, *glyphdata_files): """Return GlyphData holding data from a list of XML file paths.""" name_mapping = {} alt_name_mapping = {} production_name_mapping = {} for glyphdata_file in glyphdata_files: glyph_data = xml.etree.ElementTree.parse(glyphdata_fi...
python
def from_files(cls, *glyphdata_files): """Return GlyphData holding data from a list of XML file paths.""" name_mapping = {} alt_name_mapping = {} production_name_mapping = {} for glyphdata_file in glyphdata_files: glyph_data = xml.etree.ElementTree.parse(glyphdata_fi...
Return GlyphData holding data from a list of XML file paths.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L65-L86
googlefonts/glyphsLib
Lib/glyphsLib/__init__.py
load_to_ufos
def load_to_ufos( file_or_path, include_instances=False, family_name=None, propagate_anchors=True ): """Load an unpacked .glyphs object to UFO objects.""" if hasattr(file_or_path, "read"): font = load(file_or_path) else: with open(file_or_path, "r", encoding="utf-8") as ifile: ...
python
def load_to_ufos( file_or_path, include_instances=False, family_name=None, propagate_anchors=True ): """Load an unpacked .glyphs object to UFO objects.""" if hasattr(file_or_path, "read"): font = load(file_or_path) else: with open(file_or_path, "r", encoding="utf-8") as ifile: ...
Load an unpacked .glyphs object to UFO objects.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/__init__.py#L62-L78
googlefonts/glyphsLib
Lib/glyphsLib/__init__.py
build_masters
def build_masters( filename, master_dir, designspace_instance_dir=None, designspace_path=None, family_name=None, propagate_anchors=True, minimize_glyphs_diffs=False, normalize_ufos=False, create_background_layers=False, generate_GDEF=True, store_editor_state=True, ): """W...
python
def build_masters( filename, master_dir, designspace_instance_dir=None, designspace_path=None, family_name=None, propagate_anchors=True, minimize_glyphs_diffs=False, normalize_ufos=False, create_background_layers=False, generate_GDEF=True, store_editor_state=True, ): """W...
Write and return UFOs from the masters and the designspace defined in a .glyphs file. Args: master_dir: Directory where masters are written. designspace_instance_dir: If provided, a designspace document will be written alongside the master UFOs though no instances will be built. ...
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/__init__.py#L81-L155
googlefonts/glyphsLib
Lib/glyphsLib/cli.py
glyphs2ufo
def glyphs2ufo(options): """Converts a Glyphs.app source file into UFO masters and a designspace file.""" if options.output_dir is None: options.output_dir = os.path.dirname(options.glyphs_file) or "." if options.designspace_path is None: options.designspace_path = os.path.join( ...
python
def glyphs2ufo(options): """Converts a Glyphs.app source file into UFO masters and a designspace file.""" if options.output_dir is None: options.output_dir = os.path.dirname(options.glyphs_file) or "." if options.designspace_path is None: options.designspace_path = os.path.join( ...
Converts a Glyphs.app source file into UFO masters and a designspace file.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/cli.py#L166-L191
googlefonts/glyphsLib
Lib/glyphsLib/cli.py
ufo2glyphs
def ufo2glyphs(options): """Convert one designspace file or one or more UFOs to a Glyphs.app source file.""" import fontTools.designspaceLib import defcon sources = options.designspace_file_or_UFOs designspace_file = None if ( len(sources) == 1 and sources[0].endswith(".designsp...
python
def ufo2glyphs(options): """Convert one designspace file or one or more UFOs to a Glyphs.app source file.""" import fontTools.designspaceLib import defcon sources = options.designspace_file_or_UFOs designspace_file = None if ( len(sources) == 1 and sources[0].endswith(".designsp...
Convert one designspace file or one or more UFOs to a Glyphs.app source file.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/cli.py#L201-L252
googlefonts/glyphsLib
Lib/glyphsLib/builder/user_data.py
_has_manual_kern_feature
def _has_manual_kern_feature(font): """Return true if the GSFont contains a manually written 'kern' feature.""" return any(f for f in font.features if f.name == "kern" and not f.automatic)
python
def _has_manual_kern_feature(font): """Return true if the GSFont contains a manually written 'kern' feature.""" return any(f for f in font.features if f.name == "kern" and not f.automatic)
Return true if the GSFont contains a manually written 'kern' feature.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/user_data.py#L36-L38
googlefonts/glyphsLib
Lib/glyphsLib/builder/user_data.py
to_ufo_family_user_data
def to_ufo_family_user_data(self, ufo): """Set family-wide user data as Glyphs does.""" if not self.use_designspace: ufo.lib[FONT_USER_DATA_KEY] = dict(self.font.userData)
python
def to_ufo_family_user_data(self, ufo): """Set family-wide user data as Glyphs does.""" if not self.use_designspace: ufo.lib[FONT_USER_DATA_KEY] = dict(self.font.userData)
Set family-wide user data as Glyphs does.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/user_data.py#L58-L61
googlefonts/glyphsLib
Lib/glyphsLib/builder/user_data.py
to_ufo_master_user_data
def to_ufo_master_user_data(self, ufo, master): """Set master-specific user data as Glyphs does.""" for key in master.userData.keys(): if _user_data_has_no_special_meaning(key): ufo.lib[key] = master.userData[key] # Restore UFO data files. This code assumes that all paths are POSIX path...
python
def to_ufo_master_user_data(self, ufo, master): """Set master-specific user data as Glyphs does.""" for key in master.userData.keys(): if _user_data_has_no_special_meaning(key): ufo.lib[key] = master.userData[key] # Restore UFO data files. This code assumes that all paths are POSIX path...
Set master-specific user data as Glyphs does.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/user_data.py#L64-L73
googlefonts/glyphsLib
Lib/glyphsLib/builder/user_data.py
to_glyphs_family_user_data_from_designspace
def to_glyphs_family_user_data_from_designspace(self): """Set the GSFont userData from the designspace family-wide lib data.""" target_user_data = self.font.userData for key, value in self.designspace.lib.items(): if key == UFO2FT_FEATURE_WRITERS_KEY and value == DEFAULT_FEATURE_WRITERS: ...
python
def to_glyphs_family_user_data_from_designspace(self): """Set the GSFont userData from the designspace family-wide lib data.""" target_user_data = self.font.userData for key, value in self.designspace.lib.items(): if key == UFO2FT_FEATURE_WRITERS_KEY and value == DEFAULT_FEATURE_WRITERS: ...
Set the GSFont userData from the designspace family-wide lib data.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/user_data.py#L103-L112
googlefonts/glyphsLib
Lib/glyphsLib/builder/user_data.py
to_glyphs_family_user_data_from_ufo
def to_glyphs_family_user_data_from_ufo(self, ufo): """Set the GSFont userData from the UFO family-wide lib data.""" target_user_data = self.font.userData try: for key, value in ufo.lib[FONT_USER_DATA_KEY].items(): # Existing values taken from the designspace lib take precedence ...
python
def to_glyphs_family_user_data_from_ufo(self, ufo): """Set the GSFont userData from the UFO family-wide lib data.""" target_user_data = self.font.userData try: for key, value in ufo.lib[FONT_USER_DATA_KEY].items(): # Existing values taken from the designspace lib take precedence ...
Set the GSFont userData from the UFO family-wide lib data.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/user_data.py#L115-L125
googlefonts/glyphsLib
Lib/glyphsLib/builder/user_data.py
to_glyphs_master_user_data
def to_glyphs_master_user_data(self, ufo, master): """Set the GSFontMaster userData from the UFO master-specific lib data.""" target_user_data = master.userData for key, value in ufo.lib.items(): if _user_data_has_no_special_meaning(key): target_user_data[key] = value # Save UFO dat...
python
def to_glyphs_master_user_data(self, ufo, master): """Set the GSFontMaster userData from the UFO master-specific lib data.""" target_user_data = master.userData for key, value in ufo.lib.items(): if _user_data_has_no_special_meaning(key): target_user_data[key] = value # Save UFO dat...
Set the GSFontMaster userData from the UFO master-specific lib data.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/user_data.py#L128-L143
googlefonts/glyphsLib
Lib/glyphsLib/builder/__init__.py
to_ufos
def to_ufos( font, include_instances=False, family_name=None, propagate_anchors=True, ufo_module=defcon, minimize_glyphs_diffs=False, generate_GDEF=True, store_editor_state=True, ): """Take a GSFont object and convert it into one UFO per master. Takes in data as Glyphs.app-compa...
python
def to_ufos( font, include_instances=False, family_name=None, propagate_anchors=True, ufo_module=defcon, minimize_glyphs_diffs=False, generate_GDEF=True, store_editor_state=True, ): """Take a GSFont object and convert it into one UFO per master. Takes in data as Glyphs.app-compa...
Take a GSFont object and convert it into one UFO per master. Takes in data as Glyphs.app-compatible classes, as documented at https://docu.glyphsapp.com/ If include_instances is True, also returns the parsed instance data. If family_name is provided, the master UFOs will be given this name and on...
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/__init__.py#L25-L62
googlefonts/glyphsLib
Lib/glyphsLib/builder/__init__.py
to_designspace
def to_designspace( font, family_name=None, instance_dir=None, propagate_anchors=True, ufo_module=defcon, minimize_glyphs_diffs=False, generate_GDEF=True, store_editor_state=True, ): """Take a GSFont object and convert it into a Designspace Document + UFOS. The UFOs are available...
python
def to_designspace( font, family_name=None, instance_dir=None, propagate_anchors=True, ufo_module=defcon, minimize_glyphs_diffs=False, generate_GDEF=True, store_editor_state=True, ): """Take a GSFont object and convert it into a Designspace Document + UFOS. The UFOs are available...
Take a GSFont object and convert it into a Designspace Document + UFOS. The UFOs are available as the attribute `font` of each SourceDescriptor of the DesignspaceDocument: ufos = [source.font for source in designspace.sources] The designspace and the UFOs are not written anywhere by default, they ...
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/__init__.py#L65-L108
googlefonts/glyphsLib
Lib/glyphsLib/builder/__init__.py
to_glyphs
def to_glyphs(ufos_or_designspace, glyphs_module=classes, minimize_ufo_diffs=False): """ Take a list of UFOs or a single DesignspaceDocument with attached UFOs and converts it into a GSFont object. The GSFont object is in-memory, it's up to the user to write it to the disk if needed. This shou...
python
def to_glyphs(ufos_or_designspace, glyphs_module=classes, minimize_ufo_diffs=False): """ Take a list of UFOs or a single DesignspaceDocument with attached UFOs and converts it into a GSFont object. The GSFont object is in-memory, it's up to the user to write it to the disk if needed. This shou...
Take a list of UFOs or a single DesignspaceDocument with attached UFOs and converts it into a GSFont object. The GSFont object is in-memory, it's up to the user to write it to the disk if needed. This should be the inverse function of `to_ufos` and `to_designspace`, so we should have to_glyphs(to_...
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/__init__.py#L111-L135
4Catalyzer/flask-resty
flask_resty/spec/plugin.py
FlaskRestyPlugin.path_helper
def path_helper(self, path, view, **kwargs): """Path helper for Flask-RESTy views. :param view: An `ApiView` object. """ super(FlaskRestyPlugin, self).path_helper( path=path, view=view, **kwargs ) resource = self.get_state().views[vie...
python
def path_helper(self, path, view, **kwargs): """Path helper for Flask-RESTy views. :param view: An `ApiView` object. """ super(FlaskRestyPlugin, self).path_helper( path=path, view=view, **kwargs ) resource = self.get_state().views[vie...
Path helper for Flask-RESTy views. :param view: An `ApiView` object.
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/spec/plugin.py#L24-L55
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
class_to_value
def class_to_value(axis, ufo_class): """ >>> class_to_value('wdth', 7) 125 """ if axis == "wght": # 600.0 => 600, 250 => 250 return int(ufo_class) elif axis == "wdth": return WIDTH_CLASS_TO_VALUE[int(ufo_class)] raise NotImplementedError
python
def class_to_value(axis, ufo_class): """ >>> class_to_value('wdth', 7) 125 """ if axis == "wght": # 600.0 => 600, 250 => 250 return int(ufo_class) elif axis == "wdth": return WIDTH_CLASS_TO_VALUE[int(ufo_class)] raise NotImplementedError
>>> class_to_value('wdth', 7) 125
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L43-L54
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
user_loc_string_to_value
def user_loc_string_to_value(axis_tag, user_loc): """Go from Glyphs UI strings to user space location. Returns None if the string is invalid. >>> user_loc_string_to_value('wght', 'ExtraLight') 200 >>> user_loc_string_to_value('wdth', 'SemiCondensed') 87.5 >>> user_loc_string_to_value('wdth'...
python
def user_loc_string_to_value(axis_tag, user_loc): """Go from Glyphs UI strings to user space location. Returns None if the string is invalid. >>> user_loc_string_to_value('wght', 'ExtraLight') 200 >>> user_loc_string_to_value('wdth', 'SemiCondensed') 87.5 >>> user_loc_string_to_value('wdth'...
Go from Glyphs UI strings to user space location. Returns None if the string is invalid. >>> user_loc_string_to_value('wght', 'ExtraLight') 200 >>> user_loc_string_to_value('wdth', 'SemiCondensed') 87.5 >>> user_loc_string_to_value('wdth', 'Clearly Not From Glyphs UI')
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L67-L91
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
user_loc_value_to_class
def user_loc_value_to_class(axis_tag, user_loc): """Return the OS/2 weight or width class that is closest to the provided user location. For weight the user location is between 0 and 1000 and for width it is a percentage. >>> user_loc_value_to_class('wght', 310) 310 >>> user_loc_value_to_class(...
python
def user_loc_value_to_class(axis_tag, user_loc): """Return the OS/2 weight or width class that is closest to the provided user location. For weight the user location is between 0 and 1000 and for width it is a percentage. >>> user_loc_value_to_class('wght', 310) 310 >>> user_loc_value_to_class(...
Return the OS/2 weight or width class that is closest to the provided user location. For weight the user location is between 0 and 1000 and for width it is a percentage. >>> user_loc_value_to_class('wght', 310) 310 >>> user_loc_value_to_class('wdth', 62) 2
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L94-L112
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
user_loc_value_to_instance_string
def user_loc_value_to_instance_string(axis_tag, user_loc): """Return the Glyphs UI string (from the instance dropdown) that is closest to the provided user location. >>> user_loc_value_to_instance_string('wght', 430) 'Normal' >>> user_loc_value_to_instance_string('wdth', 150) 'Extra Expanded' ...
python
def user_loc_value_to_instance_string(axis_tag, user_loc): """Return the Glyphs UI string (from the instance dropdown) that is closest to the provided user location. >>> user_loc_value_to_instance_string('wght', 430) 'Normal' >>> user_loc_value_to_instance_string('wdth', 150) 'Extra Expanded' ...
Return the Glyphs UI string (from the instance dropdown) that is closest to the provided user location. >>> user_loc_value_to_instance_string('wght', 430) 'Normal' >>> user_loc_value_to_instance_string('wdth', 150) 'Extra Expanded'
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L115-L135
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
get_regular_master
def get_regular_master(font): """Find the "regular" master among the GSFontMasters. Tries to find the master with the passed 'regularName'. If there is no such master or if regularName is None, tries to find a base style shared between all masters (defaulting to "Regular"), and then tries to find a...
python
def get_regular_master(font): """Find the "regular" master among the GSFontMasters. Tries to find the master with the passed 'regularName'. If there is no such master or if regularName is None, tries to find a base style shared between all masters (defaulting to "Regular"), and then tries to find a...
Find the "regular" master among the GSFontMasters. Tries to find the master with the passed 'regularName'. If there is no such master or if regularName is None, tries to find a base style shared between all masters (defaulting to "Regular"), and then tries to find a master with that style name. If ...
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L512-L542
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
find_base_style
def find_base_style(masters): """Find a base style shared between all masters. Return empty string if none is found. """ if not masters: return "" base_style = (masters[0].name or "").split() for master in masters: style = master.name.split() base_style = [s for s in styl...
python
def find_base_style(masters): """Find a base style shared between all masters. Return empty string if none is found. """ if not masters: return "" base_style = (masters[0].name or "").split() for master in masters: style = master.name.split() base_style = [s for s in styl...
Find a base style shared between all masters. Return empty string if none is found.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L545-L556
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
interp
def interp(mapping, x): """Compute the piecewise linear interpolation given by mapping for input x. >>> interp(((1, 1), (2, 4)), 1.5) 2.5 """ mapping = sorted(mapping) if len(mapping) == 1: xa, ya = mapping[0] if xa == x: return ya return x for (xa, ya), ...
python
def interp(mapping, x): """Compute the piecewise linear interpolation given by mapping for input x. >>> interp(((1, 1), (2, 4)), 1.5) 2.5 """ mapping = sorted(mapping) if len(mapping) == 1: xa, ya = mapping[0] if xa == x: return ya return x for (xa, ya), ...
Compute the piecewise linear interpolation given by mapping for input x. >>> interp(((1, 1), (2, 4)), 1.5) 2.5
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L566-L581
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
AxisDefinition.get_user_loc
def get_user_loc(self, master_or_instance): """Get the user location of a Glyphs master or instance. Masters in Glyphs can have a user location in the "Axis Location" custom parameter. The user location is what the user sees on the slider in his variable-font-enabled UI. For wei...
python
def get_user_loc(self, master_or_instance): """Get the user location of a Glyphs master or instance. Masters in Glyphs can have a user location in the "Axis Location" custom parameter. The user location is what the user sees on the slider in his variable-font-enabled UI. For wei...
Get the user location of a Glyphs master or instance. Masters in Glyphs can have a user location in the "Axis Location" custom parameter. The user location is what the user sees on the slider in his variable-font-enabled UI. For weight it is a value between 0 and 1000, 400 being...
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L310-L365
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
AxisDefinition.set_user_loc
def set_user_loc(self, master_or_instance, value): """Set the user location of a Glyphs master or instance.""" if hasattr(master_or_instance, "instanceInterpolations"): # The following code is only valid for instances. # Masters also the keys `weight` and `width` but they should ...
python
def set_user_loc(self, master_or_instance, value): """Set the user location of a Glyphs master or instance.""" if hasattr(master_or_instance, "instanceInterpolations"): # The following code is only valid for instances. # Masters also the keys `weight` and `width` but they should ...
Set the user location of a Glyphs master or instance.
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L367-L418
4Catalyzer/flask-resty
flask_resty/spec/operation.py
Operation.add_parameter
def add_parameter(self, location='query', **kwargs): """Adds a new parameter to the request :param location: the 'in' field of the parameter (e.g: 'query', 'body', 'path') """ kwargs.setdefault('in', location) if kwargs['in'] != 'body': kwargs.setdefault('...
python
def add_parameter(self, location='query', **kwargs): """Adds a new parameter to the request :param location: the 'in' field of the parameter (e.g: 'query', 'body', 'path') """ kwargs.setdefault('in', location) if kwargs['in'] != 'body': kwargs.setdefault('...
Adds a new parameter to the request :param location: the 'in' field of the parameter (e.g: 'query', 'body', 'path')
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/spec/operation.py#L12-L20
4Catalyzer/flask-resty
flask_resty/spec/operation.py
Operation.add_property_to_response
def add_property_to_response(self, code='200', prop_name='data', **kwargs): """Add a property (http://json-schema.org/latest/json-schema-validation.html#anchor64) # noqa: E501 to the schema of the response identified by the code""" self['responses'] \ .setdefault(str(code), self._ne...
python
def add_property_to_response(self, code='200', prop_name='data', **kwargs): """Add a property (http://json-schema.org/latest/json-schema-validation.html#anchor64) # noqa: E501 to the schema of the response identified by the code""" self['responses'] \ .setdefault(str(code), self._ne...
Add a property (http://json-schema.org/latest/json-schema-validation.html#anchor64) # noqa: E501 to the schema of the response identified by the code
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/spec/operation.py#L22-L30
4Catalyzer/flask-resty
flask_resty/spec/operation.py
Operation.declare_response
def declare_response(self, code='200', **kwargs): """Declare a response for the specified code https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#responseObject""" # noqa: E501 self['responses'][str(code)] = self._new_operation(**kwargs)
python
def declare_response(self, code='200', **kwargs): """Declare a response for the specified code https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#responseObject""" # noqa: E501 self['responses'][str(code)] = self._new_operation(**kwargs)
Declare a response for the specified code https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#responseObject
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/spec/operation.py#L32-L35
inveniosoftware/invenio-records-rest
invenio_records_rest/schemas/fields/sanitizedhtml.py
SanitizedHTML._deserialize
def _deserialize(self, value, attr, data): """Deserialize string by sanitizing HTML.""" value = super(SanitizedHTML, self)._deserialize(value, attr, data) return bleach.clean( value, tags=self.tags, attributes=self.attrs, strip=True, ).stri...
python
def _deserialize(self, value, attr, data): """Deserialize string by sanitizing HTML.""" value = super(SanitizedHTML, self)._deserialize(value, attr, data) return bleach.clean( value, tags=self.tags, attributes=self.attrs, strip=True, ).stri...
Deserialize string by sanitizing HTML.
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/schemas/fields/sanitizedhtml.py#L55-L63
inveniosoftware/invenio-records-rest
invenio_records_rest/utils.py
build_default_endpoint_prefixes
def build_default_endpoint_prefixes(records_rest_endpoints): """Build the default_endpoint_prefixes map.""" pid_types = set() guessed = set() endpoint_prefixes = {} for key, endpoint in records_rest_endpoints.items(): pid_type = endpoint['pid_type'] pid_types.add(pid_type) i...
python
def build_default_endpoint_prefixes(records_rest_endpoints): """Build the default_endpoint_prefixes map.""" pid_types = set() guessed = set() endpoint_prefixes = {} for key, endpoint in records_rest_endpoints.items(): pid_type = endpoint['pid_type'] pid_types.add(pid_type) i...
Build the default_endpoint_prefixes map.
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/utils.py#L28-L57
inveniosoftware/invenio-records-rest
invenio_records_rest/utils.py
obj_or_import_string
def obj_or_import_string(value, default=None): """Import string or return object. :params value: Import path or class object to instantiate. :params default: Default object to return if the import fails. :returns: The imported object. """ if isinstance(value, six.string_types): return i...
python
def obj_or_import_string(value, default=None): """Import string or return object. :params value: Import path or class object to instantiate. :params default: Default object to return if the import fails. :returns: The imported object. """ if isinstance(value, six.string_types): return i...
Import string or return object. :params value: Import path or class object to instantiate. :params default: Default object to return if the import fails. :returns: The imported object.
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/utils.py#L60-L71
inveniosoftware/invenio-records-rest
invenio_records_rest/utils.py
load_or_import_from_config
def load_or_import_from_config(key, app=None, default=None): """Load or import value from config. :returns: The loaded value. """ app = app or current_app imp = app.config.get(key) return obj_or_import_string(imp, default=default)
python
def load_or_import_from_config(key, app=None, default=None): """Load or import value from config. :returns: The loaded value. """ app = app or current_app imp = app.config.get(key) return obj_or_import_string(imp, default=default)
Load or import value from config. :returns: The loaded value.
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/utils.py#L74-L81
inveniosoftware/invenio-records-rest
invenio_records_rest/utils.py
check_elasticsearch
def check_elasticsearch(record, *args, **kwargs): """Return permission that check if the record exists in ES index. :params record: A record object. :returns: A object instance with a ``can()`` method. """ def can(self): """Try to search for given record.""" search = request._method...
python
def check_elasticsearch(record, *args, **kwargs): """Return permission that check if the record exists in ES index. :params record: A record object. :returns: A object instance with a ``can()`` method. """ def can(self): """Try to search for given record.""" search = request._method...
Return permission that check if the record exists in ES index. :params record: A record object. :returns: A object instance with a ``can()`` method.
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/utils.py#L100-L112
inveniosoftware/invenio-records-rest
invenio_records_rest/utils.py
LazyPIDValue.data
def data(self): """Resolve PID from a value and return a tuple with PID and the record. :returns: A tuple with the PID and the record resolved. """ try: return self.resolver.resolve(self.value) except PIDDoesNotExistError as pid_error: raise PIDDoesNotExi...
python
def data(self): """Resolve PID from a value and return a tuple with PID and the record. :returns: A tuple with the PID and the record resolved. """ try: return self.resolver.resolve(self.value) except PIDDoesNotExistError as pid_error: raise PIDDoesNotExi...
Resolve PID from a value and return a tuple with PID and the record. :returns: A tuple with the PID and the record resolved.
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/utils.py#L133-L176
inveniosoftware/invenio-records-rest
invenio_records_rest/serializers/json.py
JSONSerializerMixin._format_args
def _format_args(): """Get JSON dump indentation and separates.""" if request and request.args.get('prettyprint'): return dict( indent=2, separators=(', ', ': '), ) else: return dict( indent=None, ...
python
def _format_args(): """Get JSON dump indentation and separates.""" if request and request.args.get('prettyprint'): return dict( indent=2, separators=(', ', ': '), ) else: return dict( indent=None, ...
Get JSON dump indentation and separates.
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/serializers/json.py#L23-L34
inveniosoftware/invenio-records-rest
invenio_records_rest/serializers/json.py
JSONSerializerMixin.serialize
def serialize(self, pid, record, links_factory=None, **kwargs): """Serialize a single record and persistent identifier. :param pid: Persistent identifier instance. :param record: Record instance. :param links_factory: Factory function for record links. """ return json.du...
python
def serialize(self, pid, record, links_factory=None, **kwargs): """Serialize a single record and persistent identifier. :param pid: Persistent identifier instance. :param record: Record instance. :param links_factory: Factory function for record links. """ return json.du...
Serialize a single record and persistent identifier. :param pid: Persistent identifier instance. :param record: Record instance. :param links_factory: Factory function for record links.
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/serializers/json.py#L36-L45
inveniosoftware/invenio-records-rest
invenio_records_rest/serializers/json.py
JSONSerializerMixin.serialize_search
def serialize_search(self, pid_fetcher, search_result, links=None, item_links_factory=None, **kwargs): """Serialize a search result. :param pid_fetcher: Persistent identifier fetcher. :param search_result: Elasticsearch search result. :param links: Dictionary of...
python
def serialize_search(self, pid_fetcher, search_result, links=None, item_links_factory=None, **kwargs): """Serialize a search result. :param pid_fetcher: Persistent identifier fetcher. :param search_result: Elasticsearch search result. :param links: Dictionary of...
Serialize a search result. :param pid_fetcher: Persistent identifier fetcher. :param search_result: Elasticsearch search result. :param links: Dictionary of links to add to response.
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/serializers/json.py#L47-L67
inveniosoftware/invenio-records-rest
invenio_records_rest/views.py
create_error_handlers
def create_error_handlers(blueprint, error_handlers_registry=None): """Create error handlers on blueprint. :params blueprint: Records API blueprint. :params error_handlers_registry: Configuration of error handlers per exception or HTTP status code and view name. The dictionary has the foll...
python
def create_error_handlers(blueprint, error_handlers_registry=None): """Create error handlers on blueprint. :params blueprint: Records API blueprint. :params error_handlers_registry: Configuration of error handlers per exception or HTTP status code and view name. The dictionary has the foll...
Create error handlers on blueprint. :params blueprint: Records API blueprint. :params error_handlers_registry: Configuration of error handlers per exception or HTTP status code and view name. The dictionary has the following structure: .. code-block:: python { ...
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/views.py#L54-L116
inveniosoftware/invenio-records-rest
invenio_records_rest/views.py
create_blueprint
def create_blueprint(endpoints): """Create Invenio-Records-REST blueprint. :params endpoints: Dictionary representing the endpoints configuration. :returns: Configured blueprint. """ endpoints = endpoints or {} blueprint = Blueprint( 'invenio_records_rest', __name__, ur...
python
def create_blueprint(endpoints): """Create Invenio-Records-REST blueprint. :params endpoints: Dictionary representing the endpoints configuration. :returns: Configured blueprint. """ endpoints = endpoints or {} blueprint = Blueprint( 'invenio_records_rest', __name__, ur...
Create Invenio-Records-REST blueprint. :params endpoints: Dictionary representing the endpoints configuration. :returns: Configured blueprint.
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/views.py#L134-L157
inveniosoftware/invenio-records-rest
invenio_records_rest/views.py
create_url_rules
def create_url_rules(endpoint, list_route=None, item_route=None, pid_type=None, pid_minter=None, pid_fetcher=None, read_permission_factory_imp=None, create_permission_factory_imp=None, update_permission_factory_imp=None, ...
python
def create_url_rules(endpoint, list_route=None, item_route=None, pid_type=None, pid_minter=None, pid_fetcher=None, read_permission_factory_imp=None, create_permission_factory_imp=None, update_permission_factory_imp=None, ...
Create Werkzeug URL rules. :param endpoint: Name of endpoint. :param list_route: Record listing URL route. Required. :param item_route: Record URL route (must include ``<pid_value>`` pattern). Required. :param pid_type: Persistent identifier type for endpoint. Required. :param pid_minter: I...
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/views.py#L160-L358