]> git.lyx.org Git - features.git/blob - src/lyxfont.h
new painter,workarea and lcolor. Read the diff/sources and ChangeLog...
[features.git] / src / lyxfont.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 1995 Matthias Ettrich
8  *
9  * ====================================================== */
10
11 #ifndef LYXFONT_H
12 #define LYXFONT_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include FORMS_H_LOCATION
19 #include "LString.h"
20 #include "debug.h"
21 #include "direction.h"
22 #include "LColor.h"
23
24 // It might happen that locale.h defines ON and OFF. This is not good
25 // for us, since we use these names below. But of course this is due
26 // to some old compilers. Than is broken when it comes to C++ scoping.
27 #include "gettext.h" // so that we are sure tht it won't be included
28 // later. 
29 #ifdef ON
30 #undef ON
31 #endif
32
33 #ifdef OFF
34 #undef OFF
35 #endif
36
37 class LyXLex;
38
39 #define NEW_BITS 1
40
41 ///
42 class LyXFont {
43 public:
44         /** The value INHERIT_* means that the font attribute is
45             inherited from the layout. In the case of layout fonts, the
46             attribute is inherited from the default font.
47             The value IGNORE_* is used with LyXFont::update() when the
48             attribute should not be changed.
49         */
50         enum FONT_FAMILY {
51                 ///
52                 ROMAN_FAMILY, // fontstruct rely on this to be 0
53                 ///
54                 SANS_FAMILY,
55                 ///
56                 TYPEWRITER_FAMILY,
57                 ///
58                 SYMBOL_FAMILY,
59                 ///
60                 INHERIT_FAMILY,
61                 ///
62                 IGNORE_FAMILY
63         };
64
65         ///
66         enum FONT_SERIES {
67                 ///
68                 MEDIUM_SERIES, // fontstruct rely on this to be 0
69                 ///
70                 BOLD_SERIES,
71                 ///
72                 INHERIT_SERIES,
73                 ///
74                 IGNORE_SERIES
75         };
76
77         ///
78         enum FONT_SHAPE {
79                 ///
80                 UP_SHAPE, // fontstruct rely on this to be 0
81                 ///
82                 ITALIC_SHAPE,
83                 ///
84                 SLANTED_SHAPE,
85                 ///
86                 SMALLCAPS_SHAPE,
87                 ///
88                 INHERIT_SHAPE,
89                 ///
90                 IGNORE_SHAPE
91         };
92
93         ///
94         enum FONT_SIZE {
95                 ///
96                 SIZE_TINY, // fontstruct rely on this to be 0
97                 ///
98                 SIZE_SCRIPT,
99                 ///
100                 SIZE_FOOTNOTE,
101                 ///
102                 SIZE_SMALL,
103                 ///
104                 SIZE_NORMAL,
105                 ///
106                 SIZE_LARGE,
107                 ///
108                 SIZE_LARGER,
109                 ///
110                 SIZE_LARGEST,
111                 ///
112                 SIZE_HUGE,
113                 ///
114                 SIZE_HUGER,
115                 ///
116                 INCREASE_SIZE,
117                 ///
118                 DECREASE_SIZE,
119                 ///
120                 INHERIT_SIZE,
121                 ///
122                 IGNORE_SIZE
123         };
124  
125         enum FONT_DIRECTION {
126                 ///
127                 LTR_DIR,
128                 ///
129                 RTL_DIR,
130                 ///
131                 TOGGLE_DIR,
132                 ///
133                 INHERIT_DIR,
134                 ///
135                 IGNORE_DIR
136         };
137
138         /// Used for emph, underbar, noun and latex toggles
139         enum FONT_MISC_STATE {
140                 ///
141                 OFF,
142                 ///
143                 ON,
144                 ///
145                 TOGGLE,
146                 ///
147                 INHERIT,
148                 ///
149                 IGNORE
150         };
151
152 #ifndef USE_PAINTER
153         ///
154         enum FONT_COLOR {
155                 ///
156                 NONE,
157                 ///
158                 BLACK,
159                 ///
160                 WHITE,
161                 ///
162                 RED,
163                 ///
164                 GREEN,
165                 ///
166                 BLUE,
167                 ///
168                 CYAN,
169                 ///
170                 MAGENTA,
171                 ///
172                 YELLOW,
173                 ///
174                 MATH,
175                 ///
176                 INSET,
177                 ///
178                 INHERIT_COLOR,
179                 ///
180                 IGNORE_COLOR
181         };
182 #endif
183         
184         /// Trick to overload constructor and make it megafast
185         enum FONT_INIT1 {
186                 ///
187                 ALL_INHERIT
188         };
189         ///
190         enum FONT_INIT2 {
191                 ///
192                 ALL_IGNORE
193         };
194         ///
195         enum FONT_INIT3 {
196                 ///
197                 ALL_SANE
198         };
199
200         ///
201         LyXFont();
202
203         /// LyXFont x(LyXFont ...) and LyXFont x = LyXFont ...
204         LyXFont(LyXFont const & x);
205  
206         /// Shortcut initialization
207         LyXFont(LyXFont::FONT_INIT1);
208         /// Shortcut initialization
209         LyXFont(LyXFont::FONT_INIT2);
210         /// Shortcut initialization
211         LyXFont(LyXFont::FONT_INIT3);
212
213         /// LyXFont x, y; x = y;
214         LyXFont& operator=(LyXFont const & x);
215  
216         /// Decreases font size by one
217         LyXFont & decSize();
218  
219         /// Increases font size by one
220         LyXFont & incSize();
221  
222         ///
223         FONT_FAMILY family() const;
224  
225         ///
226         FONT_SERIES series() const;
227  
228         ///
229         FONT_SHAPE shape() const;
230  
231         ///
232         FONT_SIZE size() const;
233  
234         ///
235         FONT_MISC_STATE emph() const;
236  
237         ///
238         FONT_MISC_STATE underbar() const;
239  
240         ///
241         FONT_MISC_STATE noun() const;
242
243         ///
244         FONT_MISC_STATE latex() const;
245
246 #ifdef USE_PAINTER
247         ///
248         LColor::color color() const;
249 #else
250         ///
251         FONT_COLOR color() const;
252 #endif
253
254         ///
255         FONT_DIRECTION direction() const;
256
257         ///
258         LyXDirection getFontDirection() const;
259         
260         ///
261         LyXFont & setFamily(LyXFont::FONT_FAMILY f);
262         ///
263         LyXFont & setSeries(LyXFont::FONT_SERIES s);
264         ///
265         LyXFont & setShape(LyXFont::FONT_SHAPE s);
266         ///
267         LyXFont & setSize(LyXFont::FONT_SIZE s);
268         ///
269         LyXFont & setEmph(LyXFont::FONT_MISC_STATE e);
270         ///
271         LyXFont & setUnderbar(LyXFont::FONT_MISC_STATE u);
272         ///
273         LyXFont & setNoun(LyXFont::FONT_MISC_STATE n);
274         ///
275         LyXFont & setLatex(LyXFont::FONT_MISC_STATE l);
276 #ifdef USE_PAINTER
277         ///
278         LyXFont & setColor(LColor::color c);
279 #else
280         ///
281         LyXFont & setColor(LyXFont::FONT_COLOR c);
282 #endif
283         ///
284         LyXFont & setDirection(LyXFont::FONT_DIRECTION d);
285
286         /// Set family after LyX text format
287         LyXFont & setLyXFamily(string const &);
288  
289         /// Set series after LyX text format
290         LyXFont & setLyXSeries(string const &);
291  
292         /// Set shape after LyX text format
293         LyXFont & setLyXShape(string const &);
294  
295         /// Set size after LyX text format
296         LyXFont & setLyXSize(string const &);
297  
298         /// Returns misc flag after LyX text format
299         LyXFont::FONT_MISC_STATE setLyXMisc(string const &);
300
301         /// Sets color after LyX text format
302         LyXFont & setLyXColor(string const &);
303  
304         /// Sets size after GUI name
305         LyXFont & setGUISize(string const &);
306  
307         /// Returns size of font in LaTeX text notation
308         string latexSize() const;
309  
310         /** Updates font settings according to request. If an
311             attribute is IGNORE, the attribute is left as it is. */
312         /* 
313          * When toggleall = true, all properties that matches the font in use
314          * will have the effect that the properties is reset to the
315          * default.  If we have a text that is TYPEWRITER_FAMILY, and is
316          * update()'ed with TYPEWRITER_FAMILY, the operation will be as if
317          * a INHERIT_FAMILY was asked for.  This is necessary for the
318          * toggle-user-defined-style button on the toolbar.
319          */
320         void update(LyXFont const & newfont, bool toggleall = false);
321  
322         /** Reduce font to fall back to template where possible.
323             Equal fields are reduced to INHERIT */
324         void reduce(LyXFont const & tmplt);
325  
326         /// Realize font from a template (INHERIT are realized)
327         LyXFont & realize(LyXFont const & tmplt);
328
329         /// Is a given font fully resolved?
330         bool resolved() const;
331  
332         /// Read a font specification from LyXLex. Used for layout files.
333         LyXFont & lyxRead(LyXLex &);
334  
335         /// Writes the changes from this font to orgfont in .lyx format in file
336         void lyxWriteChanges(LyXFont const & orgfont, ostream &) const;
337
338         /** Writes the head of the LaTeX needed to change to this font.
339             Writes to string, the head of the LaTeX needed to change
340             to this font. Returns number of chars written. Base is the
341             font state active now.
342         */
343         int latexWriteStartChanges(string &, LyXFont const & base,
344                                    LyXFont const & prev) const;
345
346         /** Writes tha tail of the LaTeX needed to chagne to this font.
347             Returns number of chars written. Base is the font state we want
348             to achieve.
349         */
350         int latexWriteEndChanges(string &, LyXFont const & base,
351                                  LyXFont const & next) const;
352  
353         /// Build GUI description of font state
354         string stateText() const;
355
356         ///
357         int maxAscent() const; 
358
359         ///
360         int maxDescent() const;
361
362         ///
363         int ascent(char c) const;
364
365         ///
366         int descent(char c) const;
367
368         ///
369         int width(char c) const;
370
371         ///
372         int lbearing(char c) const;
373
374         ///
375         int rbearing(char c) const;
376         
377         ///
378         int textWidth(char const *s, int n) const;
379
380         ///
381         int stringWidth(string const & s) const;
382
383         ///
384         int signedStringWidth(string const & s) const;
385
386         /// Draws text and returns width of text
387         int drawText(char const *, int n, Pixmap, int baseline, int x) const;
388
389         ///
390         int drawString(string const &, Pixmap pm, int baseline, int x) const;
391
392 #ifdef USE_PAINTER
393         ///
394         LColor::color realColor() const;
395 #endif
396
397         ///
398         XID getFontID() const {
399                 return getXFontstruct()->fid;
400         }
401         
402 #ifndef USE_PAINTER
403         ///
404         GC getGC() const;
405 #endif
406         ///
407         friend inline
408         bool operator==(LyXFont const & font1, LyXFont const & font2) {
409                 return font1.bits == font2.bits;
410         }
411
412         ///
413         friend inline
414         bool operator!=(LyXFont const & font1, LyXFont const & font2) {
415                 return font1.bits != font2.bits;
416         }
417
418         /// compares two fonts, ignoring the setting of the Latex part.
419         bool equalExceptLatex(LyXFont const &) const;
420
421 private:
422 #ifdef NEW_BITS
423         ///
424         struct FontBits {
425                 bool operator==(FontBits const & fb1) const {
426                         return fb1.family == family &&
427                                 fb1.series == series &&
428                                 fb1.shape == shape &&
429                                 fb1.size == size &&
430                                 fb1.color == color &&
431                                 fb1.emph == emph &&
432                                 fb1.underbar == underbar &&
433                                 fb1.noun == noun &&
434                                 fb1.latex == latex &&
435                                 fb1.direction == direction;
436                 }
437                 bool operator!=(FontBits const & fb1) const {
438                         return !(fb1 == *this);
439                 }
440                 
441                 FONT_FAMILY family;
442                 FONT_SERIES series;
443                 FONT_SHAPE shape;
444                 FONT_SIZE size;
445 #ifdef USE_PAINTER
446                 LColor::color color;
447 #else
448                 FONT_COLOR color;
449 #endif
450                 FONT_MISC_STATE emph;
451                 FONT_MISC_STATE underbar;
452                 FONT_MISC_STATE noun;
453                 FONT_MISC_STATE latex;
454                 FONT_DIRECTION direction;
455         };
456 #else
457         /// This have to be at least 32 bits, but 64 or more does not hurt
458         typedef unsigned int ui32;
459 #endif
460
461         /** Representation: bit table
462             Layout of bit table:
463                 11 1111 111 122 222 222 2233
464             Bit 012 34 567 8901 2345 678 901 234 567 8901
465                 FFF SS SSS SSSS CCCC EEE UUU NNN LLL
466                 aaa ee hhh iiii oooo mmm nnn ooo aaa
467                 mmm rr aaa zzzz llll ppp ddd uuu ttt
468
469             Bit 76543210 76543210 76543210 76543210
470                                                 --- Fam_Pos
471                                               --    Ser_Pos
472                                            ---      Sha_Pos
473                                       ----          Siz_Pos
474                                   ----              Col_Pos
475                               ---                   Emp_Pos
476                            ---                      Und_Pos
477                        - --                         Nou_Pos
478                     ---                             Lat_Pos
479                 ----                                Dir_Pos
480                 
481             Some might think this is a dirty representation, but it gives
482             us at least 25% speed-up, so why not? (Asger)
483
484             First of all it is a maintence nightmare...and now that we need
485             to enlarge the Color bits with 2 (from 4 to 6), we have a problem
486             since a 32 bit entity is not large enough... (Lgb)
487         */
488
489 #ifdef NEW_BITS
490         FontBits bits;
491 #else
492         ui32 bits;
493         
494         ///
495         enum FONT_POSITION {
496                 ///
497                 Fam_Pos =  0,
498                 ///
499                 Ser_Pos =  3,
500                 ///
501                 Sha_Pos =  5,
502                 ///
503                 Siz_Pos =  8,
504                 ///
505                 Col_Pos = 12,
506                 ///
507                 Emp_Pos = 16,
508                 ///
509                 Und_Pos = 19,
510                 ///
511                 Nou_Pos = 22,
512                 ///
513                 Lat_Pos = 25,
514                 ///
515                 Dir_Pos = 28
516         };
517
518         ///
519         enum FONT_MASK {
520                 ///
521                 Fam_Mask = 0x07,
522                 ///
523                 Ser_Mask = 0x03,
524                 ///
525                 Sha_Mask = 0x07,
526                 ///
527                 Siz_Mask = 0x0f,
528                 ///
529                 Col_Mask = 0x0f,
530                 ///
531                 Dir_Mask = 0x07,
532                 ///
533                 Misc_Mask = 0x07
534         };
535 #endif
536
537         
538 #ifdef NEW_BITS
539         /// Sane font
540         static FontBits sane;
541         
542         /// All inherit font
543         static FontBits inherit;
544  
545         /// All ignore font
546         static FontBits ignore;
547
548 #else
549         /// Sane font
550         enum {  sane = ui32(ROMAN_FAMILY) << Fam_Pos
551                 | ui32(MEDIUM_SERIES) << Ser_Pos
552                 | ui32(UP_SHAPE) << Sha_Pos
553                 | ui32(SIZE_NORMAL) << Siz_Pos
554 #ifdef USE_PAINTER
555                 | ui32(LColor::none) << Col_Pos
556 #else
557                 | ui32(NONE) << Col_Pos
558 #endif
559                 | ui32(OFF) << Emp_Pos
560                 | ui32(OFF) << Und_Pos
561                 | ui32(OFF) << Nou_Pos
562                 | ui32(OFF) << Lat_Pos
563                 | ui32(LTR_DIR) << Dir_Pos};
564         
565         /// All inherit font
566         enum{ inherit = ui32(INHERIT_FAMILY) << Fam_Pos
567                       | ui32(INHERIT_SERIES) << Ser_Pos
568                       | ui32(INHERIT_SHAPE) << Sha_Pos
569                       | ui32(INHERIT_SIZE) << Siz_Pos
570 #ifdef USE_PAINTER
571                       | ui32(LColor::inherit) << Col_Pos
572 #else
573                       | ui32(INHERIT_COLOR) << Col_Pos
574 #endif
575                       | ui32(INHERIT) << Emp_Pos
576                       | ui32(INHERIT) << Und_Pos
577                       | ui32(INHERIT) << Nou_Pos
578                       | ui32(INHERIT) << Lat_Pos
579                       | ui32(INHERIT_DIR) << Dir_Pos};
580  
581         /// All ignore font
582         enum{ ignore = ui32(IGNORE_FAMILY) << Fam_Pos
583                       | ui32(IGNORE_SERIES) << Ser_Pos
584                       | ui32(IGNORE_SHAPE) << Sha_Pos
585                       | ui32(IGNORE_SIZE) << Siz_Pos
586 #ifdef USE_PAINTER
587                       | ui32(LColor::ignore) << Col_Pos
588 #else
589                       | ui32(IGNORE_COLOR) << Col_Pos
590 #endif
591                       | ui32(IGNORE) << Emp_Pos
592                       | ui32(IGNORE) << Und_Pos
593                       | ui32(IGNORE) << Nou_Pos
594                       | ui32(IGNORE) << Lat_Pos
595                       | ui32(IGNORE_DIR) << Dir_Pos};
596 #endif
597         /// Updates a misc setting according to request
598         LyXFont::FONT_MISC_STATE setMisc(LyXFont::FONT_MISC_STATE newfont,
599                                          LyXFont::FONT_MISC_STATE org);
600
601         /// Converts logical attributes to concrete shape attribute
602         LyXFont::FONT_SHAPE realShape() const;
603
604         ///
605         XFontStruct * getXFontstruct() const;
606 };
607
608 ostream & operator<<(ostream &, LyXFont::FONT_MISC_STATE);
609
610 inline LyXFont::LyXFont()
611 {
612         bits = sane;
613 }
614
615
616 inline LyXFont::LyXFont(LyXFont const & x)
617 {
618         bits = x.bits;
619 }
620
621
622 inline LyXFont::LyXFont(LyXFont::FONT_INIT1)
623 {
624         bits = inherit;
625 }
626
627
628 inline LyXFont::LyXFont(LyXFont::FONT_INIT2)
629 {
630         bits = ignore;
631 }
632
633
634 inline LyXFont::LyXFont(LyXFont::FONT_INIT3)
635 {
636         bits = sane;
637 }
638
639
640 inline LyXFont & LyXFont::operator=(LyXFont const & x) 
641 {
642         bits = x.bits;
643         return *this;
644 }
645
646
647 #ifdef NEW_BITS
648 // You don't have to understand the stuff below :-)
649 // It works, and it's bloody fast. (Asger)
650 // And impossible to work with. (Lgb)
651
652 inline
653 LyXFont::FONT_FAMILY LyXFont::family() const 
654 {
655         return bits.family;
656 }
657
658
659 inline
660 LyXFont::FONT_SERIES LyXFont::series() const
661 {
662         return bits.series;
663 }
664
665
666 inline
667 LyXFont::FONT_SHAPE LyXFont::shape() const
668 {
669         return bits.shape;
670 }
671
672
673 inline
674 LyXFont::FONT_SIZE LyXFont::size() const
675 {
676         return bits.size;
677 }
678
679
680 inline
681 LyXFont::FONT_MISC_STATE LyXFont::emph() const
682 {
683         return bits.emph;
684 }
685
686
687 inline
688 LyXFont::FONT_MISC_STATE LyXFont::underbar() const
689 {
690         return bits.underbar;
691 }
692
693
694 inline
695 LyXFont::FONT_MISC_STATE LyXFont::noun() const
696 {
697         return bits.noun;
698 }
699
700
701 inline
702 LyXFont::FONT_MISC_STATE LyXFont::latex() const 
703 {
704         return bits.latex;
705 }
706
707
708 #ifdef USE_PAINTER
709 inline
710 LColor::color LyXFont::color() const 
711 {
712         return bits.color;
713 }
714 #else
715 inline
716 LyXFont::FONT_COLOR LyXFont::color() const 
717 {
718         return bits.color;
719 }
720 #endif
721
722
723 inline
724 LyXFont::FONT_DIRECTION LyXFont::direction() const 
725 {
726         return bits.direction;
727 }
728
729 inline
730 LyXFont & LyXFont::setFamily(LyXFont::FONT_FAMILY f)
731 {
732         bits.family = f;
733         return *this;
734 }
735
736
737 inline
738 LyXFont & LyXFont::setSeries(LyXFont::FONT_SERIES s)
739 {
740         bits.series = s;
741         return *this;
742 }
743
744
745 inline
746 LyXFont & LyXFont::setShape(LyXFont::FONT_SHAPE s)
747 {
748         bits.shape = s;
749         return *this;
750 }
751
752
753 inline
754 LyXFont & LyXFont::setSize(LyXFont::FONT_SIZE s)
755 {
756         bits.size = s;
757         return *this;
758 }
759
760
761 inline
762 LyXFont & LyXFont::setEmph(LyXFont::FONT_MISC_STATE e)
763 {
764         bits.emph = e;
765         return *this;
766 }
767
768
769 inline
770 LyXFont & LyXFont::setUnderbar(LyXFont::FONT_MISC_STATE u)
771 {
772         bits.underbar = u;
773         return *this;
774 }
775
776
777 inline
778 LyXFont & LyXFont::setNoun(LyXFont::FONT_MISC_STATE n)
779 {
780         bits.noun = n;
781         return *this;
782 }
783
784 inline
785 LyXFont & LyXFont::setLatex(LyXFont::FONT_MISC_STATE l)
786 {
787         bits.latex = l;
788         return *this;
789 }
790
791
792 #ifdef USE_PAINTER
793 inline
794 LyXFont & LyXFont::setColor(LColor::color c)
795 {
796         bits.color = c;
797         return *this;
798 }
799 #else
800 inline
801 LyXFont & LyXFont::setColor(LyXFont::FONT_COLOR c)
802 {
803         bits.color = c;
804         return *this;
805 }
806 #endif
807
808 inline
809 LyXFont & LyXFont::setDirection(LyXFont::FONT_DIRECTION d)
810 {
811         bits.direction = d;
812         return *this;
813 }
814 #else
815 // You don't have to understand the stuff below :-)
816 // It works, and it's bloody fast. (Asger)
817 // And impossible to work with. (Lgb)
818
819 inline LyXFont::FONT_FAMILY LyXFont::family() const 
820 {
821         return LyXFont::FONT_FAMILY((bits >> Fam_Pos) & Fam_Mask);
822 }
823
824
825 inline LyXFont::FONT_SERIES LyXFont::series() const
826 {
827         return LyXFont::FONT_SERIES((bits >> Ser_Pos) & Ser_Mask);
828 }
829
830
831 inline LyXFont::FONT_SHAPE LyXFont::shape() const
832 {
833         return LyXFont::FONT_SHAPE((bits >> Sha_Pos) & Sha_Mask);
834 }
835
836
837 inline LyXFont::FONT_SIZE LyXFont::size() const
838 {
839         return LyXFont::FONT_SIZE((bits >> Siz_Pos) & Siz_Mask);
840 }
841
842
843 inline LyXFont::FONT_MISC_STATE LyXFont::emph() const
844 {
845         return LyXFont::FONT_MISC_STATE((bits >> Emp_Pos) & Misc_Mask);
846 }
847
848
849 inline LyXFont::FONT_MISC_STATE LyXFont::underbar() const
850 {
851         return LyXFont::FONT_MISC_STATE((bits >> Und_Pos) & Misc_Mask);
852 }
853
854
855 inline LyXFont::FONT_MISC_STATE LyXFont::noun() const
856 {
857         return LyXFont::FONT_MISC_STATE((bits >> Nou_Pos) & Misc_Mask);
858 }
859
860
861 inline LyXFont::FONT_MISC_STATE LyXFont::latex() const 
862 {
863         return LyXFont::FONT_MISC_STATE((bits >> Lat_Pos) & Misc_Mask);
864 }
865
866
867 #ifdef USE_PAINTER
868 inline LColor::color LyXFont::color() const 
869 {
870         return LColor::color((bits >> Col_Pos) & Col_Mask);
871 }
872 #else
873 inline LyXFont::FONT_COLOR LyXFont::color() const
874 {
875         return FONT_COLOR((bits >> Col_Pos) & Col_Mask);
876 }
877 #endif
878
879
880 inline LyXFont::FONT_DIRECTION LyXFont::direction() const 
881 {
882         return LyXFont::FONT_DIRECTION((bits >> Dir_Pos) & Dir_Mask);
883 }
884
885 inline LyXFont & LyXFont::setFamily(LyXFont::FONT_FAMILY f)
886 {
887         bits &= ~(Fam_Mask << Fam_Pos);
888         bits |= ui32(f) << Fam_Pos;
889         return *this;
890 }
891
892
893 inline LyXFont & LyXFont::setSeries(LyXFont::FONT_SERIES s)
894 {
895         bits &= ~(Ser_Mask << Ser_Pos);
896         bits |= ui32(s) << Ser_Pos;
897         return *this;
898 }
899
900
901 inline LyXFont & LyXFont::setShape(LyXFont::FONT_SHAPE s)
902 {
903         bits &= ~(Sha_Mask << Sha_Pos);
904         bits |= ui32(s) << Sha_Pos;
905         return *this;
906 }
907
908
909 inline LyXFont & LyXFont::setSize(LyXFont::FONT_SIZE s)
910 {
911         bits &= ~(Siz_Mask << Siz_Pos);
912         bits |= ui32(s) << Siz_Pos;
913         return *this;
914 }
915
916
917 inline LyXFont & LyXFont::setEmph(LyXFont::FONT_MISC_STATE e)
918 {
919         bits &= ~(Misc_Mask << Emp_Pos);
920         bits |= ui32(e) << Emp_Pos;
921         return *this;
922 }
923
924
925 inline LyXFont & LyXFont::setUnderbar(LyXFont::FONT_MISC_STATE u)
926 {
927         bits &= ~(Misc_Mask << Und_Pos);
928         bits |= ui32(u) << Und_Pos;
929         return *this;
930 }
931
932
933 inline LyXFont & LyXFont::setNoun(LyXFont::FONT_MISC_STATE n)
934 {
935         bits &= ~(Misc_Mask << Nou_Pos);
936         bits |= ui32(n) << Nou_Pos;
937         return *this;
938 }
939
940 inline LyXFont & LyXFont::setLatex(LyXFont::FONT_MISC_STATE l)
941 {
942         bits &= ~(Misc_Mask << Lat_Pos);
943         bits |= ui32(l) << Lat_Pos;
944         return *this;
945 }
946
947
948 #ifdef USE_PAINTER
949 inline LyXFont & LyXFont::setColor(LColor::color c)
950 {
951         bits &= ~(Col_Mask << Col_Pos);
952         bits |= ui32(c) << Col_Pos;
953         return *this;
954 }
955 #else
956 inline LyXFont & LyXFont::setColor(LyXFont::FONT_COLOR c)
957 {
958         bits &= ~(Col_Mask << Col_Pos);
959         bits |= ui32(c) << Col_Pos;
960         return *this;
961 }
962 #endif
963
964 inline LyXFont & LyXFont::setDirection(LyXFont::FONT_DIRECTION d)
965 {
966         bits &= ~(Dir_Mask << Dir_Pos);
967         bits |= ui32(d) << Dir_Pos;
968         return *this;
969 }
970 #endif
971
972 #endif