markFeature.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright 2015 Google Inc. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from ufo2ft.kernFeatureWriter import KernFeatureWriter
  15. from ufo2ft.makeotfParts import FeatureOTFCompiler
  16. class RobotoFeatureCompiler(FeatureOTFCompiler):
  17. def precompile(self):
  18. self.overwriteFeatures = True
  19. def setupAnchorPairs(self):
  20. self.anchorPairs = [
  21. ["top", "_marktop"],
  22. ["bottom", "_markbottom"],
  23. ["top_dd", "_marktop_dd"],
  24. ["bottom_dd", "_markbottom_dd"],
  25. ["rhotichook", "_markrhotichook"],
  26. ["top0315", "_marktop0315"],
  27. ["parent_top", "_markparent_top"],
  28. ["parenthesses.w1", "_markparenthesses.w1"],
  29. ["parenthesses.w2", "_markparenthesses.w2"],
  30. ["parenthesses.w3", "_markparenthesses.w3"]]
  31. self.mkmkAnchorPairs = [
  32. ["mkmktop", "_marktop"],
  33. ["mkmkbottom_acc", "_markbottom"],
  34. # By providing a pair with accent anchor _bottom and no base anchor,
  35. # we designate all glyphs with _bottom as accents (so that they will
  36. # be used as base glyphs for mkmk features) without generating any
  37. # positioning rules actually using this anchor (which is instead
  38. # used to generate composite glyphs). This is all for consistency
  39. # with older roboto versions.
  40. ["", "_bottom"],
  41. ]
  42. self.ligaAnchorPairs = []
  43. class RobotoKernWriter(KernFeatureWriter):
  44. leftFeaClassRe = r"@_(.+)_L$"
  45. rightFeaClassRe = r"@_(.+)_R$"