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