MCPcopy Create free account
hub / github.com/Panzerschrek/Chasm-Reverse / TextDrawerSoft

Method TextDrawerSoft

PanzerChasm/text_drawer_soft.cpp:13–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11{
12
13TextDrawerSoft::TextDrawerSoft(
14 const RenderingContextSoft& rendering_context,
15 const GameResources& game_resources )
16 : rendering_context_(rendering_context)
17{
18 const Vfs::FileContent font_file= game_resources.vfs->ReadFile( FontParams::font_file_name );
19 const CelTextureHeader* const cel_header= reinterpret_cast<const CelTextureHeader*>( font_file.data() );
20 const unsigned char* const font_data= font_file.data() + sizeof(CelTextureHeader);
21
22 const unsigned int pixel_count= cel_header->size[0] * cel_header->size[1];
23
24 for( unsigned int c= 0u; c < FontParams::colors_variations; c++ )
25 {
26 unsigned char* const font_data_shifted= font_texture_data_ + FontParams::atlas_width * FontParams::atlas_height * c;
27
28 ColorShift(
29 FontParams::start_inner_color, FontParams::end_inner_color,
30 FontParams::color_shifts[c],
31 pixel_count,
32 font_data,
33 font_data_shifted );
34
35 // Hack. Move "slider" letter from code '\0';
36 for( unsigned int y= 0; y < FontParams::letter_place_height; y++ )
37 std::memcpy(
38 font_data_shifted + FontParams::atlas_width * y + FontParams::letter_place_width * ( c_slider_back_letter_code & 15u ) + FontParams::atlas_width * FontParams::letter_place_height * ( c_slider_back_letter_code >> 4u ),
39 font_data_shifted + FontParams::atlas_width * y,
40 FontParams::letter_place_width );
41 }
42
43 CalculateLettersWidth(
44 font_data,
45 letters_width_ );
46
47 letters_width_[ c_slider_back_letter_code ]= letters_width_[0]; // Move slider letter.
48}
49
50TextDrawerSoft::~TextDrawerSoft()
51{}

Callers

nothing calls this directly

Calls 3

ColorShiftFunction · 0.85
CalculateLettersWidthFunction · 0.85
ReadFileMethod · 0.80

Tested by

no test coverage detected