KiCad PCB EDA Suite
text_utils.h File Reference
#include <utf8.h>
#include <vector>

Go to the source code of this file.

Functions

std::pair< UTF8, std::vector< bool > > ProcessOverbars (const UTF8 &aText)
 Processes a text to extract the raw text and overbar flags. More...
 

Function Documentation

std::pair<UTF8, std::vector<bool> > ProcessOverbars ( const UTF8 aText)

Processes a text to extract the raw text and overbar flags.

Parameters
aTextis the text to be processed.
Returns
Pair of raw text and overbar enable flags for each character in the raw text.

Definition at line 27 of file text_utils.cpp.

References UTF8::ubegin(), and UTF8::uend().

Referenced by KIGFX::OPENGL_GAL::BitmapText(), and KIGFX::STROKE_FONT::drawSingleLineText().

28 {
29  UTF8 text;
30  std::vector<bool> flags;
31  bool overbar = false;
32 
33  for( UTF8::uni_iter chIt = aText.ubegin(), end = aText.uend(); chIt < end; ++chIt )
34  {
35  if( *chIt == '~' )
36  {
37  if( ++chIt >= end )
38  break;
39 
40  // It was a single tilda, it toggles overbar
41  if( *chIt != '~' )
42  overbar = !overbar;
43 
44  // If it is a double tilda, just process the second one
45  }
46 
47  // remember: *chIt is not necessary a ASCII7 char.
48  // it is an unsigned giving a multibyte char in UTF8 strings
49  text += *chIt;
50 
51  flags.push_back( overbar );
52  }
53 
54  return std::make_pair( text, flags );
55 }
Class UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion supp...
Definition: utf8.h:73
uni_iter ubegin() const
Function ubegin returns a uni_iter initialized to the start of "this" UTF8 byte sequence.
Definition: utf8.h:285
class uni_iter is a non-mutating iterator that walks through unicode code points in the UTF8 encoded ...
Definition: utf8.h:207
uni_iter uend() const
Function uend returns a uni_iter initialized to the end of "this" UTF8 byte sequence.
Definition: utf8.h:294