afdko

C/C++ Architectural Changes: develop → addfeatures

This is an AI summary of the changes to our C/C++ code, for reference.

Summary Statistics

Overall Code Metrics

By Component

Major Architectural Changes

1. Unified Binary (c/afdko/)

NEW component providing single entry point for all C++ tools

Files:

Design:

2. makeotf → addfeatures Transformation

Major refactoring and renaming:

File structure changes:

develop: c/makeotf/
  source/
    cbpriv.c, cb.c, mac.c, c_main.c, file.c, fcdb.c, main.cpp
  lib/
    typecomp/    (14 files)
    cffread/     (2 files)
    hotconv/     (26+ files - feature compilation)
    api/         (headers)

addfeatures: c/addfeatures/
  cb.cpp, fcdb.cpp, main.cpp    (C→C++ conversions)
  hotconv/     (30 files, many C→C++ conversions)
    - BASE.cpp, GDEF.cpp, GPOS.cpp, GSUB.cpp
    - MVAR.cpp, STAT.cpp (new variable font support)
    - OS_2.cpp, head.cpp, hmtx.cpp, vmtx.cpp
    - FeatParser.cpp, FeatLexer.cpp, FeatVisitor.cpp
    - cmap.cpp, name.cpp, post.cpp, maxp.cpp
    - hot.cpp, otl.cpp, sfnt.cpp
  pstoken/     (parser component)
  include/
  utils/

Eliminated components (moved to shared or removed):

3. Shared Library Restructuring

Structure flattening:

develop: c/shared/source/
  tx_shared/tx_shared.c
  uforead/uforead.c
  ufowrite/ufowrite.c
  t1read/t1read.c
  t1cstr/t1cstr.c
  t2cstr/t2cstr.c
  svgwrite/svgwrite.c
  pdfwrite/pdfwrite.c
  ... (many subdirectories)

addfeatures: c/shared/
  tx_shared.cpp       (C→C++)
  uforead.cpp         (C→C++)
  ufowrite.cpp        (C→C++)
  t1read.cpp          (C→C++)
  t1cstr.cpp          (C→C++)
  t2cstr.cpp          (C→C++)
  svgwrite.cpp        (C→C++)
  pdfwrite.cpp        (C→C++)
  sfntread.cpp        (C→C++)
  sfntwrite.cpp       (C→C++)
  ttread.cpp          (C→C++)
  goadb.cpp           (NEW - GOADB support from makeotfexe)
  designspace.cpp     (NEW - designspace parsing)
  varsupport.cpp      (NEW - variable font support)
  ... (flat structure, many more .cpp files)

Key changes:

4. C → C++ Conversions

Major files converted:

Total converted: ~94 .c files eliminated, ~67 new .cpp files created

5. Integration Points

tx integration:

Version integration:

6. What Was Kept as C

Still .c files (76 total):

Benefits of These Changes

  1. Code Reduction: 15% fewer source files overall
  2. Modern C++: Better type safety, RAII, standard library usage
  3. Unified Architecture: Single binary entry point, better code sharing
  4. Flatter Structure: Easier navigation, reduced directory nesting
  5. Better Separation: Clear boundaries between font I/O, feature compilation, proof generation
  6. Variable Font Support: New capabilities enabled by cleaner architecture
  7. Build Integration: Proper version flow, better CMake integration
  8. Performance: Fast dispatch for C++ commands, Python fallback for flexibility

Migration Impact

For users: Transparent - same functionality, different implementation For developers:

Technical Debt Addressed

  1. Eliminated deeply nested directory structures
  2. Consolidated redundant font reading/writing code
  3. Removed obsolete Type 1 → CFF conversion from addfeatures
  4. Unified command dispatch architecture
  5. Modernized C → C++ for better maintainability
  6. Integrated version string generation properly

Future Path

This architectural foundation supports: