Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code for V3 #34

Merged
merged 3 commits into from
Apr 28, 2024
Merged

Refactor code for V3 #34

merged 3 commits into from
Apr 28, 2024

Conversation

moi15moi
Copy link
Owner

@moi15moi moi15moi commented Jan 7, 2024

Refactor a big part of the code.

I tried to create multiple class so they all have only one or few responsibility (font_parser still has a lot, but it is still the only one in this case).

Changes

  • Now, we distinct a font file from a font face.
    There are now 2 kind of font face. "Variable" is for variable font and "Normal" for the rest.
  • Know what is the language of a family name or a exact name
  • From a FontFace, get the best name depending of the OS language via ABCFontFace.get_best_family_name/ABCFontFace.get_best_exact_name. The user can also query a family name from a BCP47 tag via ABCFontFace.get_family_name_from_lang/ABCFontFace.get_exact_name_from_lang
  • Users can know implement their own ass document reader. They just need to extend the class ABCAssDocument
  • Users can create their own strategy to find a font. They simply need to implement FontSelectionStrategy.
    Also, the user can choose between 2 strategy (FontSelectionStrategyLibass and FontSelectionStrategyVSFilter)
  • Know if a font is a font collection (TTC/OTC file)
  • Know what is the font type (opentype/truetype)
  • Create a FontCollection class. It has the same responsabilities has the old FontLoader. The new FontLoader now only load the font cache, load a batch of fonts and load the system fonts.
  • Add need_faux_bold attribute to FontResult
  • Resolve the issue Fonts with same name same weight and same italic #8
  • Implemented typing for all the package. mypy doesn't report any errors

Also, there are a lot of test that have been done. Now, we have a coverage of ~93% of the code (on the latest version, 2.1.4, it was 81%).

font_collector/font/name.py Outdated Show resolved Hide resolved
**Changes**
- Now, we distinct a font file from a font face.
There are now 2 kind of font face. "Variable" is for [variable font](https://fonts.google.com/knowledge/introducing_type/introducing_variable_fonts) and "Normal" for the rest.
- Know what is the language of a family name or a exact name
- From a FontFace, get the best name depending of the OS language via ``ABCFontFace.get_best_family_name``/``ABCFontFace.get_best_exact_name``. The user can also query a family name from a BCP47 tag via ``ABCFontFace.get_family_name_from_lang``/``ABCFontFace.get_exact_name_from_lang``
- Users can know implement their own ass document reader. They just need to extend the class ABCAssDocument
- Users can create their own strategy to find a font. They simply need to implement FontSelectionStrategy.
Also, the user can choose between 2 strategy (FontSelectionStrategyLibass and FontSelectionStrategyVSFilter)
- Know if a font is a font collection (TTC/OTC file)
- Know what is the font type (opentype/truetype)
- Create a FontCollection class. It has the same responsabilities has the old FontLoader. The new FontLoader now only load the font cache, load a batch of fonts and load the system fonts.
- Add ``need_faux_bold`` attribute to ``FontResult``
- Resolve the issue #8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant